@evlop/commons 1.0.195 → 1.0.196
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pathHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/pathHelper.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"pathHelper.d.ts","sourceRoot":"","sources":["../../../src/helpers/pathHelper.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,UA0B7D"}
|
@@ -4,33 +4,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.generatePath = void 0;
|
7
|
-
const lodash_1 = require("lodash");
|
8
7
|
const query_string_1 = __importDefault(require("query-string"));
|
9
8
|
function generatePath(pathTemplate, params) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
21
|
-
else if (!isOptional) {
|
22
|
-
pathSegments.push(part);
|
23
|
-
}
|
9
|
+
if (!pathTemplate || !params)
|
10
|
+
return pathTemplate;
|
11
|
+
const paramsCopy = Object.assign({}, params);
|
12
|
+
// Replace placeholders in the path
|
13
|
+
let path = String(pathTemplate).replace(/:\w+/g, (match) => {
|
14
|
+
const paramKey = match.substring(1); // Remove the ':' prefix
|
15
|
+
if (paramsCopy[paramKey] !== undefined) {
|
16
|
+
const value = paramsCopy[paramKey];
|
17
|
+
delete paramsCopy[paramKey]; // Remove the param from the copy to avoid duplicating in the query string
|
18
|
+
return encodeURIComponent(value);
|
24
19
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return path
|
20
|
+
return match;
|
21
|
+
});
|
22
|
+
// Use query-string to stringify the remaining params from the copy
|
23
|
+
const query = query_string_1.default.stringify(paramsCopy);
|
24
|
+
// Append query string if it's not empty
|
25
|
+
if (query) {
|
26
|
+
path += `?${query}`;
|
27
|
+
}
|
28
|
+
return path;
|
34
29
|
}
|
35
30
|
exports.generatePath = generatePath;
|
36
31
|
//# sourceMappingURL=pathHelper.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pathHelper.js","sourceRoot":"","sources":["../../../src/helpers/pathHelper.ts"],"names":[],"mappings":";;;;;;AAAA,
|
1
|
+
{"version":3,"file":"pathHelper.js","sourceRoot":"","sources":["../../../src/helpers/pathHelper.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAuC;AAEvC,SAAgB,YAAY,CAAC,YAAoB,EAAE,MAAW;IAE1D,IAAI,CAAC,YAAY,IAAI,CAAC,MAAM;QAAE,OAAO,YAAY,CAAC;IAElD,MAAM,UAAU,qBAAQ,MAAM,CAAE,CAAC;IAEjC,mCAAmC;IACnC,IAAI,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACvD,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB;QAC7D,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;YACpC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;YACnC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,0EAA0E;YACvG,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;SACpC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,mEAAmE;IACnE,MAAM,KAAK,GAAG,sBAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAEhD,wCAAwC;IACxC,IAAI,KAAK,EAAE;QACP,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;KACvB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AA1BD,oCA0BC"}
|