@pnpm/resolving.jsr-specifier-parser 1100.0.1 → 1100.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +7 -4
  2. package/package.json +4 -2
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PnpmError } from '@pnpm/error';
2
+ import validateNpmPackageName from 'validate-npm-package-name';
2
3
  export function parseJsrSpecifier(rawSpecifier, alias) {
3
4
  if (!rawSpecifier.startsWith('jsr:'))
4
5
  return null;
@@ -39,12 +40,14 @@ function jsrToNpmPackageName(jsrPkgName) {
39
40
  if (jsrPkgName[0] !== '@') {
40
41
  throw new PnpmError('MISSING_JSR_PACKAGE_SCOPE', 'Package names from JSR must have a scope');
41
42
  }
42
- const sepIndex = jsrPkgName.indexOf('/');
43
- if (sepIndex === -1) {
43
+ // The returned name is used in registry URLs and metadata cache file paths,
44
+ // so anything that is not a valid npm package name must never make it through.
45
+ if (!validateNpmPackageName(jsrPkgName).validForOldPackages) {
44
46
  throw new PnpmError('INVALID_JSR_PACKAGE_NAME', `The package name '${jsrPkgName}' is invalid`);
45
47
  }
46
- const scope = jsrPkgName.substring(0, sepIndex);
48
+ const sepIndex = jsrPkgName.indexOf('/');
49
+ const scope = jsrPkgName.substring('@'.length, sepIndex);
47
50
  const name = jsrPkgName.substring(sepIndex + '/'.length);
48
- return `@jsr/${scope.substring(1)}__${name}`;
51
+ return `@jsr/${scope}__${name}`;
49
52
  }
50
53
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/resolving.jsr-specifier-parser",
3
- "version": "1100.0.1",
3
+ "version": "1100.0.2",
4
4
  "description": "Parser of jsr specifiers",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,11 +28,13 @@
28
28
  "!*.map"
29
29
  ],
30
30
  "dependencies": {
31
+ "validate-npm-package-name": "7.0.2",
31
32
  "@pnpm/error": "1100.0.1"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@jest/globals": "30.4.1",
35
- "@pnpm/resolving.jsr-specifier-parser": "1100.0.1"
36
+ "@types/validate-npm-package-name": "^4.0.2",
37
+ "@pnpm/resolving.jsr-specifier-parser": "1100.0.2"
36
38
  },
37
39
  "engines": {
38
40
  "node": ">=22.13"