@koine/utils 1.0.46 → 1.0.49
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/node/index.js +1 -0
- package/node/removeUrlQueryParams.js +25 -0
- package/package.json +1 -1
- package/removeUrlQueryParams.d.ts +8 -0
- package/removeUrlQueryParams.js +21 -0
package/index.d.ts
CHANGED
|
@@ -127,6 +127,7 @@ export * from "./removeDuplicatesByKey";
|
|
|
127
127
|
export * from "./removeDuplicatesComparing";
|
|
128
128
|
export * from "./removeIndexesFromArray";
|
|
129
129
|
export * from "./removeTrailingSlash";
|
|
130
|
+
export * from "./removeUrlQueryParams";
|
|
130
131
|
export * from "./roundTo";
|
|
131
132
|
export * from "./serializeCookie";
|
|
132
133
|
export * from "./setCookie";
|
package/index.js
CHANGED
|
@@ -128,6 +128,7 @@ export * from "./removeDuplicatesByKey";
|
|
|
128
128
|
export * from "./removeDuplicatesComparing";
|
|
129
129
|
export * from "./removeIndexesFromArray";
|
|
130
130
|
export * from "./removeTrailingSlash";
|
|
131
|
+
export * from "./removeUrlQueryParams";
|
|
131
132
|
export * from "./roundTo";
|
|
132
133
|
export * from "./serializeCookie";
|
|
133
134
|
export * from "./setCookie";
|
package/node/index.js
CHANGED
|
@@ -131,6 +131,7 @@ tslib_1.__exportStar(require("./removeDuplicatesByKey"), exports);
|
|
|
131
131
|
tslib_1.__exportStar(require("./removeDuplicatesComparing"), exports);
|
|
132
132
|
tslib_1.__exportStar(require("./removeIndexesFromArray"), exports);
|
|
133
133
|
tslib_1.__exportStar(require("./removeTrailingSlash"), exports);
|
|
134
|
+
tslib_1.__exportStar(require("./removeUrlQueryParams"), exports);
|
|
134
135
|
tslib_1.__exportStar(require("./roundTo"), exports);
|
|
135
136
|
tslib_1.__exportStar(require("./serializeCookie"), exports);
|
|
136
137
|
tslib_1.__exportStar(require("./setCookie"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeUrlQueryParams = void 0;
|
|
4
|
+
var buildUrlQueryString_1 = require("./buildUrlQueryString");
|
|
5
|
+
var getUrlQueryParams_1 = require("./getUrlQueryParams");
|
|
6
|
+
/**
|
|
7
|
+
* Remove the given keys from the given URL query parameters
|
|
8
|
+
*
|
|
9
|
+
* @category location
|
|
10
|
+
* @pure
|
|
11
|
+
*/
|
|
12
|
+
function removeUrlQueryParams(url, paramsToRemove) {
|
|
13
|
+
if (paramsToRemove === void 0) { paramsToRemove = []; }
|
|
14
|
+
var parts = url.split("?");
|
|
15
|
+
var allParams = (0, getUrlQueryParams_1.default)(url);
|
|
16
|
+
var params = {};
|
|
17
|
+
for (var key in allParams) {
|
|
18
|
+
if (!paramsToRemove.includes(key)) {
|
|
19
|
+
params[key] = allParams[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return parts[0] + (0, buildUrlQueryString_1.default)(params);
|
|
23
|
+
}
|
|
24
|
+
exports.removeUrlQueryParams = removeUrlQueryParams;
|
|
25
|
+
exports.default = removeUrlQueryParams;
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import buildUrlQueryString from "./buildUrlQueryString";
|
|
2
|
+
import getUrlQueryParams from "./getUrlQueryParams";
|
|
3
|
+
/**
|
|
4
|
+
* Remove the given keys from the given URL query parameters
|
|
5
|
+
*
|
|
6
|
+
* @category location
|
|
7
|
+
* @pure
|
|
8
|
+
*/
|
|
9
|
+
export function removeUrlQueryParams(url, paramsToRemove) {
|
|
10
|
+
if (paramsToRemove === void 0) { paramsToRemove = []; }
|
|
11
|
+
var parts = url.split("?");
|
|
12
|
+
var allParams = getUrlQueryParams(url);
|
|
13
|
+
var params = {};
|
|
14
|
+
for (var key in allParams) {
|
|
15
|
+
if (!paramsToRemove.includes(key)) {
|
|
16
|
+
params[key] = allParams[key];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return parts[0] + buildUrlQueryString(params);
|
|
20
|
+
}
|
|
21
|
+
export default removeUrlQueryParams;
|