@pnpm/resolving.jsr-specifier-parser 1100.0.0 → 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.
- package/README.md +1 -1
- package/lib/index.js +7 -4
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Parser of jsr specifiers
|
|
4
4
|
|
|
5
5
|
<!--@shields('npm')-->
|
|
6
|
-
[](https://
|
|
6
|
+
[](https://npmx.dev/package/@pnpm/resolving.jsr-specifier-parser)
|
|
7
7
|
<!--/@-->
|
|
8
8
|
|
|
9
9
|
## Installation
|
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
|
-
|
|
43
|
-
|
|
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
|
|
48
|
+
const sepIndex = jsrPkgName.indexOf('/');
|
|
49
|
+
const scope = jsrPkgName.substring('@'.length, sepIndex);
|
|
47
50
|
const name = jsrPkgName.substring(sepIndex + '/'.length);
|
|
48
|
-
return `@jsr/${scope
|
|
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.
|
|
3
|
+
"version": "1100.0.2",
|
|
4
4
|
"description": "Parser of jsr specifiers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"funding": "https://opencollective.com/pnpm",
|
|
12
|
-
"repository":
|
|
13
|
-
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/resolving/jsr-specifier-parser"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/resolving/jsr-specifier-parser#readme",
|
|
14
17
|
"bugs": {
|
|
15
18
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
16
19
|
},
|
|
@@ -25,10 +28,13 @@
|
|
|
25
28
|
"!*.map"
|
|
26
29
|
],
|
|
27
30
|
"dependencies": {
|
|
28
|
-
"
|
|
31
|
+
"validate-npm-package-name": "7.0.2",
|
|
32
|
+
"@pnpm/error": "1100.0.1"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@
|
|
35
|
+
"@jest/globals": "30.4.1",
|
|
36
|
+
"@types/validate-npm-package-name": "^4.0.2",
|
|
37
|
+
"@pnpm/resolving.jsr-specifier-parser": "1100.0.2"
|
|
32
38
|
},
|
|
33
39
|
"engines": {
|
|
34
40
|
"node": ">=22.13"
|