@lwrjs/shared-utils 0.22.8 → 0.22.10

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/build/cjs/fs.cjs CHANGED
@@ -126,7 +126,12 @@ function normalizeToFileUrl(filePath, rootDir) {
126
126
  return filePath;
127
127
  }
128
128
  const replacedPath = filePath.replace(ROOT_DIR_REGEX, rootDir);
129
- const fullPath = import_path.default.resolve(rootDir, replacedPath);
129
+ const fullPath = import_path.default.isAbsolute(replacedPath) ? toForwardSlash(import_path.default.normalize(replacedPath)) : toForwardSlash(import_path.default.join(rootDir, replacedPath));
130
+ if (fullPath.startsWith("/")) {
131
+ const fileUrl = new URL("file://");
132
+ fileUrl.pathname = fullPath.replace(/%(?![0-9A-Fa-f]{2})/g, "%25");
133
+ return fileUrl.href;
134
+ }
130
135
  return import_url.default.pathToFileURL(fullPath).href;
131
136
  }
132
137
  function normalizeFromFileURL(fileURL, basePath) {
@@ -28,7 +28,6 @@ __export(exports, {
28
28
  getMrtSsgRoot: () => getMrtSsgRoot,
29
29
  getSsgAppRelativePath: () => getSsgAppRelativePath
30
30
  });
31
- var import_path = __toModule(require("path"));
32
31
  var import_fs = __toModule(require("./fs.cjs"));
33
32
  var MRT_BASE_URL = `/mobify/bundle/${process.env.BUNDLE_ID || "development"}/`;
34
33
  var DEFAULT_SSG_ROOT = "site";
@@ -39,5 +38,5 @@ function getMrtArtifactUrl(basePath, ssgRoot, artifactPath = "") {
39
38
  return (0, import_fs.joinUrlPath)(basePath, MRT_BASE_URL, ssgRoot, artifactPath);
40
39
  }
41
40
  function getMrtSsgRoot(staticSiteGenerator) {
42
- return import_path.default.join(getSsgAppRelativePath(staticSiteGenerator));
41
+ return getSsgAppRelativePath(staticSiteGenerator);
43
42
  }
package/build/es/fs.js CHANGED
@@ -123,7 +123,29 @@ export function normalizeToFileUrl(filePath, rootDir) {
123
123
  return filePath;
124
124
  }
125
125
  const replacedPath = filePath.replace(ROOT_DIR_REGEX, rootDir);
126
- const fullPath = pathLib.resolve(rootDir, replacedPath);
126
+ // Use path.normalize (not path.resolve) to collapse double slashes from
127
+ // $rootDir replacement (e.g. trailing slash in rootDir) without injecting
128
+ // a Windows drive letter.
129
+ const fullPath = pathLib.isAbsolute(replacedPath)
130
+ ? toForwardSlash(pathLib.normalize(replacedPath))
131
+ : toForwardSlash(pathLib.join(rootDir, replacedPath));
132
+ // For POSIX paths use the WHATWG URL API instead of url.pathToFileURL().
133
+ // pathToFileURL internally calls path.resolve(), which on Windows injects
134
+ // the current drive letter (e.g. C:) into POSIX-style absolute paths.
135
+ //
136
+ // The WHATWG URL pathname setter encodes characters in the "path
137
+ // percent-encode set" (spaces, #, ?, etc.) but U+0025 (%) is NOT in that
138
+ // set. Bare % is passed through unchanged because the parser assumes it
139
+ // is already part of an encoded sequence. pathToFileURL treats % as a
140
+ // literal character and encodes it to %25. The regex below pre-encodes
141
+ // bare % (not followed by two hex digits) so the output matches
142
+ // pathToFileURL for all special characters.
143
+ // See: https://url.spec.whatwg.org/#url-path-segment-string (path percent-encode set)
144
+ if (fullPath.startsWith('/')) {
145
+ const fileUrl = new URL('file://');
146
+ fileUrl.pathname = fullPath.replace(/%(?![0-9A-Fa-f]{2})/g, '%25');
147
+ return fileUrl.href;
148
+ }
127
149
  return url.pathToFileURL(fullPath).href;
128
150
  }
129
151
  export function normalizeFromFileURL(fileURL, basePath) {
@@ -1,4 +1,3 @@
1
- import path from 'path';
2
1
  import { joinUrlPath } from './fs.js';
3
2
  // MRT has a specific URL to fetch associated artifacts from the deployed MRT bundle
4
3
  const MRT_BASE_URL = `/mobify/bundle/${process.env.BUNDLE_ID || 'development'}/`;
@@ -17,6 +16,6 @@ export function getMrtArtifactUrl(basePath, ssgRoot, artifactPath = '') {
17
16
  * Get the root directory of the static config in the mrt lambda
18
17
  */
19
18
  export function getMrtSsgRoot(staticSiteGenerator) {
20
- return path.join(getSsgAppRelativePath(staticSiteGenerator));
19
+ return getSsgAppRelativePath(staticSiteGenerator);
21
20
  }
22
21
  //# sourceMappingURL=mrt-utils.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.22.8",
7
+ "version": "0.22.10",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  "build/**/*.d.ts"
38
38
  ],
39
39
  "dependencies": {
40
- "@lwrjs/diagnostics": "0.22.8",
40
+ "@lwrjs/diagnostics": "0.22.10",
41
41
  "es-module-lexer": "^1.5.4",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "magic-string": "^0.30.9",
@@ -50,7 +50,7 @@
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.22.8",
53
+ "@lwrjs/types": "0.22.10",
54
54
  "@types/mime-types": "2.1.4",
55
55
  "@types/path-to-regexp": "^1.7.0",
56
56
  "memfs": "^4.13.0"
@@ -58,5 +58,5 @@
58
58
  "engines": {
59
59
  "node": ">=22.0.0"
60
60
  },
61
- "gitHead": "66f71f33f5b12fa4e7c7969f0a6239a590c999d1"
61
+ "gitHead": "52b77087a10567ad62b48bde04607c627580105d"
62
62
  }