@ms-cloudpack/path-string-parsing 1.2.3 → 1.2.4
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/lib/parseImportString.js
CHANGED
|
@@ -19,7 +19,7 @@ export function parseImportString(importString = '') {
|
|
|
19
19
|
}
|
|
20
20
|
const matches = importString.match(
|
|
21
21
|
// 1: packageName 2: version 3: importPath
|
|
22
|
-
/^\/?((?:@[-\w.:]+\/)?[-\w.:]+)(?:@([-\w.]+))?(
|
|
22
|
+
/^\/?((?:@[-\w.:]+\/)?[-\w.:]+)(?:@([-\w.]+))?(?:([-\w./]+))?/) || [];
|
|
23
23
|
return {
|
|
24
24
|
packageName: matches[1] || '.',
|
|
25
25
|
version: matches[2] || '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseImportString.js","sourceRoot":"","sources":["../src/parseImportString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAcnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAY,GAAG,EAAE;IACjD,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QAClC,kGAAkG;QAClG,2BAA2B;QAC3B,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;IACrE,CAAC;IAED,MAAM,OAAO,GACX,YAAY,CAAC,KAAK;IAChB,0DAA0D;IAC1D,
|
|
1
|
+
{"version":3,"file":"parseImportString.js","sourceRoot":"","sources":["../src/parseImportString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAcnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAY,GAAG,EAAE;IACjD,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QAClC,kGAAkG;QAClG,2BAA2B;QAC3B,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;IACrE,CAAC;IAED,MAAM,OAAO,GACX,YAAY,CAAC,KAAK;IAChB,0DAA0D;IAC1D,8DAA8D,CAC/D,IAAI,EAAE,CAAC;IAEV,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG;QAC9B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACzB,UAAU,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KAC9C,CAAC;AACJ,CAAC","sourcesContent":["import { normalizeRelativePath } from './normalizeRelativePath.js';\n\nexport type ImportStringResult = {\n /** Package name, or `'.'` for the current package */\n packageName: string;\n /** Optional package version (default: empty string) */\n version: string;\n /**\n * Optional import path (default: `'.'`).\n * If this is set to a non-default value, it will be normalized to start with `./`.\n */\n importPath: string;\n};\n\n/**\n * Parse an import path: usually this will be a standard JS import, but this function also allows\n * an optional `@version` suffix after the package name.\n *\n * Examples of supported import strings:\n * - `foo`\n * - `foo@1.2.3`\n * - `foo@1.2.3/path/to/file`\n * - `@foo/bar`\n * - `@foo/bar@1.2.3`\n * - `@foo/bar@1.2.3/path/to/file`\n */\nexport function parseImportString(importString = ''): ImportStringResult {\n if (/^\\.\\.?\\//.test(importString)) {\n // If it's a relative path (with forward slash), return as-is, since it doesn't need normalization\n // and won't have a version\n return { packageName: '.', version: '', importPath: importString };\n }\n\n const matches =\n importString.match(\n // 1: packageName 2: version 3: importPath\n /^\\/?((?:@[-\\w.:]+\\/)?[-\\w.:]+)(?:@([-\\w.]+))?(?:([-\\w./]+))?/,\n ) || [];\n\n return {\n packageName: matches[1] || '.',\n version: matches[2] || '',\n importPath: normalizeRelativePath(matches[3]),\n };\n}\n"]}
|