@readyfor/api-client-base 1.157.0-pr1539.c723da0 → 1.157.0-pr1540.babe532
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/dist/index.mjs +17 -1
- package/dist/requestUrl.js +17 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -145,9 +145,25 @@ const createVoidFetcher = (customRequestInit = {}, options = {}) => (input, requ
|
|
|
145
145
|
throw error;
|
|
146
146
|
});
|
|
147
147
|
// src/requestUrl.ts
|
|
148
|
+
const UNSAFE_PATH_SEGMENT_CHARS = /[/?#\\\u0000-\u001f\u007f]/;
|
|
149
|
+
const isSafePathSegment = (segment) => {
|
|
150
|
+
let decoded;
|
|
151
|
+
try {
|
|
152
|
+
decoded = decodeURIComponent(segment);
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const trimmed = decoded.replace(/^ +| +$/g, "");
|
|
157
|
+
return trimmed !== "." && trimmed !== ".." && !UNSAFE_PATH_SEGMENT_CHARS.test(decoded);
|
|
158
|
+
};
|
|
148
159
|
const __internal__requestUrl = (rawPath, { path: pathParams = {}, query } = {}) => {
|
|
149
160
|
const config = store.getState();
|
|
150
|
-
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") +
|
|
161
|
+
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") + rawPath.replace(/\{([^}]+)\}/g, (placeholder, key) => {
|
|
162
|
+
if (!Object.prototype.hasOwnProperty.call(pathParams, key)) return placeholder;
|
|
163
|
+
const segment = String(pathParams[key]);
|
|
164
|
+
if (!isSafePathSegment(segment)) throw new Error(`Invalid path parameter: ${key}`);
|
|
165
|
+
return segment;
|
|
166
|
+
});
|
|
151
167
|
return query ? `${path}?${qs.stringify(query)}` : path;
|
|
152
168
|
};
|
|
153
169
|
export { HTTPError, __internal__requestUrl, buildRequestInitWithDefaultConfig, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createStore, createTextFetcher, createVoidFetcher, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus, isZodError, mergeHeadersInit, mergeRequestInit, schemaForType, setApiClientConfig, store, toHeadersInit };
|
package/dist/requestUrl.js
CHANGED
|
@@ -4,9 +4,25 @@ const require_apiClientConfigStore = require("./apiClientConfigStore.js");
|
|
|
4
4
|
let qs = require("qs");
|
|
5
5
|
qs = require_runtime.__toESM(qs);
|
|
6
6
|
// src/requestUrl.ts
|
|
7
|
+
const UNSAFE_PATH_SEGMENT_CHARS = /[/?#\\\u0000-\u001f\u007f]/;
|
|
8
|
+
const isSafePathSegment = (segment) => {
|
|
9
|
+
let decoded;
|
|
10
|
+
try {
|
|
11
|
+
decoded = decodeURIComponent(segment);
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const trimmed = decoded.replace(/^ +| +$/g, "");
|
|
16
|
+
return trimmed !== "." && trimmed !== ".." && !UNSAFE_PATH_SEGMENT_CHARS.test(decoded);
|
|
17
|
+
};
|
|
7
18
|
const __internal__requestUrl = (rawPath, { path: pathParams = {}, query } = {}) => {
|
|
8
19
|
const config = require_apiClientConfigStore.store.getState();
|
|
9
|
-
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") +
|
|
20
|
+
const path = (config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "") + rawPath.replace(/\{([^}]+)\}/g, (placeholder, key) => {
|
|
21
|
+
if (!Object.prototype.hasOwnProperty.call(pathParams, key)) return placeholder;
|
|
22
|
+
const segment = String(pathParams[key]);
|
|
23
|
+
if (!isSafePathSegment(segment)) throw new Error(`Invalid path parameter: ${key}`);
|
|
24
|
+
return segment;
|
|
25
|
+
});
|
|
10
26
|
return query ? `${path}?${qs.default.stringify(query)}` : path;
|
|
11
27
|
};
|
|
12
28
|
exports.__internal__requestUrl = __internal__requestUrl;
|