@f5xc-salesdemos/pi-utils 19.45.0 → 19.46.0
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/package.json +2 -2
- package/src/xcsh-context-resolver.ts +19 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5xc-salesdemos/pi-utils",
|
|
4
|
-
"version": "19.
|
|
4
|
+
"version": "19.46.0",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://github.com/f5xc-salesdemos/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/bun": "^1.3",
|
|
42
|
-
"@f5xc-salesdemos/pi-natives": "19.
|
|
42
|
+
"@f5xc-salesdemos/pi-natives": "19.46.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"bun": ">=1.3.7"
|
|
@@ -163,17 +163,28 @@ export function isSafeContextName(name: string): boolean {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
* Normalize an API URL
|
|
166
|
+
* Normalize an API URL to its origin (`https://host[:port]`) — the canonical
|
|
167
|
+
* stored form for a context endpoint, shared verbatim by the xcsh shell and the
|
|
168
|
+
* VS Code extension.
|
|
167
169
|
*
|
|
168
|
-
* The
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
170
|
+
* The stored value must be the bare origin only: no path, query, fragment, or
|
|
171
|
+
* trailing slash. Callers append `/api/...` themselves, so the endpoint stays a
|
|
172
|
+
* single consistent value. This also defuses the protocol-relative host
|
|
173
|
+
* collapse: the shared resource library joins URLs by raw concatenation
|
|
174
|
+
* (`${apiUrl}${path}`), and a leftover path or trailing slash would produce a
|
|
175
|
+
* `//` that `new URL()` parses as an authority — collapsing the host to a bare
|
|
176
|
+
* label and breaking TLS altname verification.
|
|
174
177
|
*/
|
|
175
178
|
export function normalizeApiUrl(apiUrl: string): string {
|
|
176
|
-
|
|
179
|
+
if (typeof apiUrl !== "string") return apiUrl;
|
|
180
|
+
const trimmed = apiUrl.trim();
|
|
181
|
+
try {
|
|
182
|
+
return new URL(trimmed).origin;
|
|
183
|
+
} catch {
|
|
184
|
+
// Not a parseable absolute URL (input validation should prevent this);
|
|
185
|
+
// fall back to stripping trailing slashes so we never worsen a bad value.
|
|
186
|
+
return trimmed.replace(/\/+$/, "");
|
|
187
|
+
}
|
|
177
188
|
}
|
|
178
189
|
|
|
179
190
|
function defaultGitTracker(filePath: string): Promise<boolean> {
|