Repository: facebook/jest
File: packages/jest-resolve/src/resolver.ts (TypeScript)

Code before:
            /\$([0-9]+)/g,
            (_, index) => matches[parseInt(index, 10)],
          )
      : (moduleName: string) => moduleName;
  }

  private _isAliasModule(moduleName: string): boolean {
    const moduleNameMapper = this._options.moduleNameMapper;
    if (!moduleNameMapper) {
      return false;
    }

    return moduleNameMapper.some(({regex}) => regex.test(moduleName));
  }

  isCoreModule(moduleName: string): boolean {
    return (
      this._options.hasCoreModules &&
      (isBuiltinModule(moduleName) || moduleName.startsWith('node:')) &&
      !this._isAliasModule(moduleName)
    );
  }

  isNodePath(moduleName: string): boolean {
    return moduleName.startsWith('node:');
  }

  getModule(name: string): string | null {
    return this._moduleMap.getModule(
      name,
      this._options.defaultPlatform,
      this._supportsNativePlatform,
    );
  }

  getModulePath(from: string, moduleName: string): string {
    if (moduleName[0] !== '.' || path.isAbsolute(moduleName)) {
      return moduleName;
    }
    return path.normalize(`${path.dirname(from)}/${moduleName}`);
  }

  getPackage(name: string): string | null {
    return this._moduleMap.getPackage(
      name,
      this._options.defaultPlatform,
      this._supportsNativePlatform,
    );
  }

  getMockModule(from: string, name: string): string | null {

Review comment (suggestion):
Just above `isCoreModule` method has the same check: `moduleName.startsWith('node:'))`. The logic of removing the `'node:'` prefix is also repeated here and there. Wouldn’t it be cleaner to normalize the module specifier before passing it around with something like this:

```ts
normalizeModuleSpecifier(specifier: string): string {
  return specifier.startsWith('node:')
    ? specifier.slice('node:'.length)
    : specifier;
}
```

Code after:
          )
      : (moduleName: string) => moduleName;
  }

  private _isAliasModule(moduleName: string): boolean {
    const moduleNameMapper = this._options.moduleNameMapper;
    if (!moduleNameMapper) {
      return false;
    }

    return moduleNameMapper.some(({regex}) => regex.test(moduleName));
  }

  isCoreModule(moduleName: string): boolean {
    return (
      this._options.hasCoreModules &&
      (isBuiltinModule(moduleName) || moduleName.startsWith('node:')) &&
      !this._isAliasModule(moduleName)
    );
  }

  normalizeCoreModuleSpecifier(specifier: string): string {
    return specifier.startsWith('node:')
      ? specifier.slice('node:'.length)
      : specifier;
  }

  getModule(name: string): string | null {
    return this._moduleMap.getModule(
      name,
      this._options.defaultPlatform,
      this._supportsNativePlatform,
    );
  }

  getModulePath(from: string, moduleName: string): string {
    if (moduleName[0] !== '.' || path.isAbsolute(moduleName)) {
      return moduleName;
    }
    return path.normalize(`${path.dirname(from)}/${moduleName}`);
  }

  getPackage(name: string): string | null {
    return this._moduleMap.getPackage(
      name,
      this._options.defaultPlatform,
      this._supportsNativePlatform,
    );
  }

  getMockModule(