@ms-cloudpack/path-string-parsing 1.1.3 → 1.2.1

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { safeRelativePath } from './safeRelativePath.js';
2
+ export { normalizeRelativePath } from './normalizeRelativePath.js';
2
3
  export { slash } from './slash.js';
3
4
  export { parseImportString, type ImportStringResult } from './parseImportString.js';
4
5
  export { parseNamedImports } from './parseNamedImports.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { safeRelativePath } from './safeRelativePath.js';
2
+ export { normalizeRelativePath } from './normalizeRelativePath.js';
2
3
  export { slash } from './slash.js';
3
4
  export { parseImportString } from './parseImportString.js';
4
5
  export { parseNamedImports } from './parseNamedImports.js';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { safeRelativePath } from './safeRelativePath.js';\nexport { slash } from './slash.js';\nexport { parseImportString, type ImportStringResult } from './parseImportString.js';\nexport { parseNamedImports } from './parseNamedImports.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { safeRelativePath } from './safeRelativePath.js';\nexport { normalizeRelativePath } from './normalizeRelativePath.js';\nexport { slash } from './slash.js';\nexport { parseImportString, type ImportStringResult } from './parseImportString.js';\nexport { parseNamedImports } from './parseNamedImports.js';\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Normalize a path:
3
+ * - If it's empty, undefined, or `.`, return `.`.
4
+ * - If it's relative, normalize slashes and ensure it starts with `./`.
5
+ * - If it starts with `/`, add a leading `.` (this is an absolute path but is sometimes treated
6
+ * as package-relative)
7
+ * - If it's an absolute Windows path (starts with a drive letter), throw an error.
8
+ * - If it's absolute, throw an error (since this likely indicates a bug in the calling code).
9
+ *
10
+ * Note that this will NOT remove a trailing slash (if present).
11
+ */
12
+ export declare function normalizeRelativePath(originalPath: string | undefined): string;
13
+ //# sourceMappingURL=normalizeRelativePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeRelativePath.d.ts","sourceRoot":"","sources":["../src/normalizeRelativePath.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CA6B9E"}
@@ -0,0 +1,37 @@
1
+ import { slash } from './slash.js';
2
+ /**
3
+ * Normalize a path:
4
+ * - If it's empty, undefined, or `.`, return `.`.
5
+ * - If it's relative, normalize slashes and ensure it starts with `./`.
6
+ * - If it starts with `/`, add a leading `.` (this is an absolute path but is sometimes treated
7
+ * as package-relative)
8
+ * - If it's an absolute Windows path (starts with a drive letter), throw an error.
9
+ * - If it's absolute, throw an error (since this likely indicates a bug in the calling code).
10
+ *
11
+ * Note that this will NOT remove a trailing slash (if present).
12
+ */
13
+ export function normalizeRelativePath(originalPath) {
14
+ if (!originalPath || originalPath === '.') {
15
+ return '.';
16
+ }
17
+ // Throw on an absolute Windows path: this is definitely absolute regardless of the context it
18
+ // came from, and if the calling code attempts to join it to another path as if it was relative,
19
+ // that will have bad results. It's more likely on Windows that we could unintentionally end up
20
+ // with an absolute path since there's no way to do relative paths across drive letters
21
+ // (path.relative() will return an absolute path), so we throw here to make it clear that
22
+ // Cloudpack needs to have specific handling for any cases where that might be possible.
23
+ if (/^[a-zA-Z]:[\\/]/.test(originalPath)) {
24
+ throw new Error(`Received an absolute path where a relative path was expected: ${originalPath}.\n` +
25
+ 'This indicates a bug in Cloudpack, likely due to calling path.relative() with two Windows paths ' +
26
+ 'on different drives (which returns an absolute path) and then assuming the result is relative.');
27
+ }
28
+ // Ensure we have the right slashes.
29
+ const normalizedPath = slash(originalPath);
30
+ if (normalizedPath[0] === '/') {
31
+ // Technically a path starting with / is absolute, but it's possible that package.json
32
+ // entry points like "main" could also use a leading slash to indicate the package root.
33
+ return '.' + normalizedPath;
34
+ }
35
+ return normalizedPath.startsWith('./') ? normalizedPath : `./${normalizedPath}`;
36
+ }
37
+ //# sourceMappingURL=normalizeRelativePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeRelativePath.js","sourceRoot":"","sources":["../src/normalizeRelativePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAgC;IACpE,IAAI,CAAC,YAAY,IAAI,YAAY,KAAK,GAAG,EAAE,CAAC;QAC1C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,8FAA8F;IAC9F,gGAAgG;IAChG,+FAA+F;IAC/F,uFAAuF;IACvF,yFAAyF;IACzF,wFAAwF;IACxF,IAAI,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACb,iEAAiE,YAAY,KAAK;YAChF,kGAAkG;YAClG,gGAAgG,CACnG,CAAC;IACJ,CAAC;IAED,oCAAoC;IACpC,MAAM,cAAc,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAE3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QAC9B,sFAAsF;QACtF,wFAAwF;QACxF,OAAO,GAAG,GAAG,cAAc,CAAC;IAC9B,CAAC;IAED,OAAO,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,cAAc,EAAE,CAAC;AAClF,CAAC","sourcesContent":["import { slash } from './slash.js';\n\n/**\n * Normalize a path:\n * - If it's empty, undefined, or `.`, return `.`.\n * - If it's relative, normalize slashes and ensure it starts with `./`.\n * - If it starts with `/`, add a leading `.` (this is an absolute path but is sometimes treated\n * as package-relative)\n * - If it's an absolute Windows path (starts with a drive letter), throw an error.\n * - If it's absolute, throw an error (since this likely indicates a bug in the calling code).\n *\n * Note that this will NOT remove a trailing slash (if present).\n */\nexport function normalizeRelativePath(originalPath: string | undefined): string {\n if (!originalPath || originalPath === '.') {\n return '.';\n }\n\n // Throw on an absolute Windows path: this is definitely absolute regardless of the context it\n // came from, and if the calling code attempts to join it to another path as if it was relative,\n // that will have bad results. It's more likely on Windows that we could unintentionally end up\n // with an absolute path since there's no way to do relative paths across drive letters\n // (path.relative() will return an absolute path), so we throw here to make it clear that\n // Cloudpack needs to have specific handling for any cases where that might be possible.\n if (/^[a-zA-Z]:[\\\\/]/.test(originalPath)) {\n throw new Error(\n `Received an absolute path where a relative path was expected: ${originalPath}.\\n` +\n 'This indicates a bug in Cloudpack, likely due to calling path.relative() with two Windows paths ' +\n 'on different drives (which returns an absolute path) and then assuming the result is relative.',\n );\n }\n\n // Ensure we have the right slashes.\n const normalizedPath = slash(originalPath);\n\n if (normalizedPath[0] === '/') {\n // Technically a path starting with / is absolute, but it's possible that package.json\n // entry points like \"main\" could also use a leading slash to indicate the package root.\n return '.' + normalizedPath;\n }\n\n return normalizedPath.startsWith('./') ? normalizedPath : `./${normalizedPath}`;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { safeRelativePath } from './safeRelativePath.js';
1
+ import { normalizeRelativePath } from './normalizeRelativePath.js';
2
2
  /**
3
3
  * Parse an import path: usually this will be a standard JS import, but this function also allows
4
4
  * an optional `@version` suffix after the package name.
@@ -18,7 +18,7 @@ export function parseImportString(importString = '') {
18
18
  return {
19
19
  packageName: matches[1] || '.',
20
20
  version: matches[2] || '',
21
- importPath: safeRelativePath(matches[3]),
21
+ importPath: normalizeRelativePath(matches[3]),
22
22
  };
23
23
  }
24
24
  //# sourceMappingURL=parseImportString.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseImportString.js","sourceRoot":"","sources":["../src/parseImportString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAazD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAY,GAAG,EAAE;IACjD,MAAM,OAAO,GACX,YAAY,CAAC,KAAK;IAChB,0DAA0D;IAC1D,gEAAgE,CACjE,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,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import { safeRelativePath } from './safeRelativePath.js';\n\nexport type ImportStringResult = {\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 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: safeRelativePath(matches[3]),\n };\n}\n"]}
1
+ {"version":3,"file":"parseImportString.js","sourceRoot":"","sources":["../src/parseImportString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAanE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAY,GAAG,EAAE;IACjD,MAAM,OAAO,GACX,YAAY,CAAC,KAAK;IAChB,0DAA0D;IAC1D,gEAAgE,CACjE,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 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 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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"parseNamedImports.js","sourceRoot":"","sources":["../src/parseNamedImports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,yEAAyE;IACzE,qDAAqD;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAC9B,kdAAkd,CACnd,CAAC;IACF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,mCAAmC;IACnC,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;IACD,2DAA2D;IAC3D,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACd,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACvB;IACD,6DAA6D;IAC7D,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACd,kDAAkD;QAClD,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CAAC;QAC/E,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;YACtC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;SAC5B;KACF;IAED,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;QACd,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACjB;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Parses an import string into its component parts.\n * @param importLine - The import string to parse.\n * @returns A string array with the named imports, default and/or '*'.\n */\nexport function parseNamedImports(importLine: string): string[] {\n // Regex from: https://github.com/antonkc/MOR/blob/main/matchJsImports.md\n // With some edits to catch exports * from \"package\".\n const matches = importLine.match(\n /(?<=(?:[\\s\\n;])|^)(?:(?:import|export)[\\s\\n]*((?:(?<=[\\s\\n])type)?)(?=[\\n\\s*{])[\\s\\n]*)((?:(?:[_$\\w][_$\\w0-9]*)(?:[\\s\\n]+(?:as[\\s\\n]+(?:[_$\\w][_$\\w0-9]*)))?(?=(?:[\\n\\s]*,[\\n\\s]*[{*])|(?:[\\n\\s]+from)))?)[\\s\\n,]*((?:\\*[\\n\\s]*(?:as[\\s\\n]+(?:[_$\\w][_$\\w0-9]*))(?=[\\n\\s]+from))?|\\*)[\\s\\n,]*((?:\\{[n\\s]*(?:(?:[_$\\w][_$\\w0-9]*)(?:[\\s\\n]+(?:as[\\s\\n]+(?:[_$\\w][_$\\w0-9]*)))?[\\s\\n]*,?[\\s\\n]*)*\\}(?=[\\n\\s]*from))?)(?:[\\s\\n]*((?:from)?))[\\s\\n]*(?:[\"']([^\"']*)([\"']))[\\s\\n]*?;?/,\n );\n const names: string[] = [];\n // If no matches return empty array\n if (matches === null) {\n return names;\n }\n // If there is a default export, push it to the names array\n if (matches[2]) {\n names.push('default');\n }\n // If there is a namespace export, push it to the names array\n if (matches[4]) {\n // Clean out the braces, whitespace, and get alias\n const namedImports = matches[4].matchAll(/([\\w$]+)(?:\\s+as\\s+[\\w$]+(?:,)?)?/g);\n for (const namedImport of namedImports) {\n names.push(namedImport[1]);\n }\n }\n\n if (matches[3]) {\n names.push('*');\n }\n\n return names;\n}\n"]}
1
+ {"version":3,"file":"parseNamedImports.js","sourceRoot":"","sources":["../src/parseNamedImports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,yEAAyE;IACzE,qDAAqD;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAC9B,kdAAkd,CACnd,CAAC;IACF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,mCAAmC;IACnC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,2DAA2D;IAC3D,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC;IACD,6DAA6D;IAC7D,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACf,kDAAkD;QAClD,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CAAC;QAC/E,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Parses an import string into its component parts.\n * @param importLine - The import string to parse.\n * @returns A string array with the named imports, default and/or '*'.\n */\nexport function parseNamedImports(importLine: string): string[] {\n // Regex from: https://github.com/antonkc/MOR/blob/main/matchJsImports.md\n // With some edits to catch exports * from \"package\".\n const matches = importLine.match(\n /(?<=(?:[\\s\\n;])|^)(?:(?:import|export)[\\s\\n]*((?:(?<=[\\s\\n])type)?)(?=[\\n\\s*{])[\\s\\n]*)((?:(?:[_$\\w][_$\\w0-9]*)(?:[\\s\\n]+(?:as[\\s\\n]+(?:[_$\\w][_$\\w0-9]*)))?(?=(?:[\\n\\s]*,[\\n\\s]*[{*])|(?:[\\n\\s]+from)))?)[\\s\\n,]*((?:\\*[\\n\\s]*(?:as[\\s\\n]+(?:[_$\\w][_$\\w0-9]*))(?=[\\n\\s]+from))?|\\*)[\\s\\n,]*((?:\\{[n\\s]*(?:(?:[_$\\w][_$\\w0-9]*)(?:[\\s\\n]+(?:as[\\s\\n]+(?:[_$\\w][_$\\w0-9]*)))?[\\s\\n]*,?[\\s\\n]*)*\\}(?=[\\n\\s]*from))?)(?:[\\s\\n]*((?:from)?))[\\s\\n]*(?:[\"']([^\"']*)([\"']))[\\s\\n]*?;?/,\n );\n const names: string[] = [];\n // If no matches return empty array\n if (matches === null) {\n return names;\n }\n // If there is a default export, push it to the names array\n if (matches[2]) {\n names.push('default');\n }\n // If there is a namespace export, push it to the names array\n if (matches[4]) {\n // Clean out the braces, whitespace, and get alias\n const namedImports = matches[4].matchAll(/([\\w$]+)(?:\\s+as\\s+[\\w$]+(?:,)?)?/g);\n for (const namedImport of namedImports) {\n names.push(namedImport[1]);\n }\n }\n\n if (matches[3]) {\n names.push('*');\n }\n\n return names;\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  /**
2
- * If the given relative path is non-empty, ensure it starts with `./`.
3
- * Returns `.` if the given path is empty or undefined (or already `.`).
2
+ * @deprecated Use `normalizeRelativePath`.
4
3
  */
5
4
  export declare function safeRelativePath(originalPath: string | undefined): string;
6
5
  //# sourceMappingURL=safeRelativePath.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safeRelativePath.d.ts","sourceRoot":"","sources":["../src/safeRelativePath.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAezE"}
1
+ {"version":3,"file":"safeRelativePath.d.ts","sourceRoot":"","sources":["../src/safeRelativePath.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEzE"}
@@ -1,20 +1,8 @@
1
- import { slash } from './slash.js';
1
+ import { normalizeRelativePath } from './normalizeRelativePath.js';
2
2
  /**
3
- * If the given relative path is non-empty, ensure it starts with `./`.
4
- * Returns `.` if the given path is empty or undefined (or already `.`).
3
+ * @deprecated Use `normalizeRelativePath`.
5
4
  */
6
5
  export function safeRelativePath(originalPath) {
7
- if (!originalPath || originalPath === '.') {
8
- return '.';
9
- }
10
- // Ensure we have the right slashes.
11
- originalPath = slash(originalPath);
12
- if (originalPath.startsWith('/')) {
13
- return '.' + originalPath;
14
- }
15
- else if (originalPath.startsWith('./')) {
16
- return originalPath;
17
- }
18
- return `./${originalPath}`;
6
+ return normalizeRelativePath(originalPath);
19
7
  }
20
8
  //# sourceMappingURL=safeRelativePath.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"safeRelativePath.js","sourceRoot":"","sources":["../src/safeRelativePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAAgC;IAC/D,IAAI,CAAC,YAAY,IAAI,YAAY,KAAK,GAAG,EAAE;QACzC,OAAO,GAAG,CAAC;KACZ;IAED,oCAAoC;IACpC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAEnC,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAChC,OAAO,GAAG,GAAG,YAAY,CAAC;KAC3B;SAAM,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACxC,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,KAAK,YAAY,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import { slash } from './slash.js';\n\n/**\n * If the given relative path is non-empty, ensure it starts with `./`.\n * Returns `.` if the given path is empty or undefined (or already `.`).\n */\nexport function safeRelativePath(originalPath: string | undefined): string {\n if (!originalPath || originalPath === '.') {\n return '.';\n }\n\n // Ensure we have the right slashes.\n originalPath = slash(originalPath);\n\n if (originalPath.startsWith('/')) {\n return '.' + originalPath;\n } else if (originalPath.startsWith('./')) {\n return originalPath;\n }\n\n return `./${originalPath}`;\n}\n"]}
1
+ {"version":3,"file":"safeRelativePath.js","sourceRoot":"","sources":["../src/safeRelativePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAAgC;IAC/D,OAAO,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { normalizeRelativePath } from './normalizeRelativePath.js';\n\n/**\n * @deprecated Use `normalizeRelativePath`.\n */\nexport function safeRelativePath(originalPath: string | undefined): string {\n return normalizeRelativePath(originalPath);\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.3"
8
+ "packageVersion": "7.39.4"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/path-string-parsing",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "description": "Common path-related string parsing utilities for Cloudpack",
5
5
  "license": "MIT",
6
6
  "type": "module",