@turbox3d/shared
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -143,2 +143,16 @@ import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
}); | ||
} | ||
export function updateQueryStringParameter(url, key, value) { | ||
if (!value) { | ||
return url; | ||
} | ||
var re = new RegExp("([?&])".concat(key, "=.*?(&|$)"), 'i'); | ||
var separator = url.indexOf('?') !== -1 ? '&' : '?'; | ||
if (url.match(re)) { | ||
return url.replace(re, "$1".concat(key, "=").concat(value, "$2")); | ||
} | ||
return "".concat(url).concat(separator).concat(key, "=").concat(value); | ||
} |
@@ -24,2 +24,3 @@ "use strict"; | ||
exports.sortBy = sortBy; | ||
exports.updateQueryStringParameter = updateQueryStringParameter; | ||
@@ -193,2 +194,17 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
}); | ||
} | ||
function updateQueryStringParameter(url, key, value) { | ||
if (!value) { | ||
return url; | ||
} | ||
var re = new RegExp("([?&])".concat(key, "=.*?(&|$)"), 'i'); | ||
var separator = url.indexOf('?') !== -1 ? '&' : '?'; | ||
if (url.match(re)) { | ||
return url.replace(re, "$1".concat(key, "=").concat(value, "$2")); | ||
} | ||
return "".concat(url).concat(separator).concat(key, "=").concat(value); | ||
} |
{ | ||
"name": "@turbox3d/shared", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "turbox shared internal utility", | ||
@@ -65,3 +65,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "8bab9aea3963d03bf57b3d143e05d8c7d02fb8a1" | ||
"gitHead": "87982e50da3997de90c0e4272db3c0007ddb62c9" | ||
} |
@@ -151,1 +151,13 @@ import { isSymbol } from './lang'; | ||
} | ||
export function updateQueryStringParameter(url: string, key: string, value: string) { | ||
if (!value) { | ||
return url; | ||
} | ||
const re = new RegExp(`([?&])${key}=.*?(&|$)`, 'i'); | ||
const separator = url.indexOf('?') !== -1 ? '&' : '?'; | ||
if (url.match(re)) { | ||
return url.replace(re, `$1${key}=${value}$2`); | ||
} | ||
return `${url}${separator}${key}=${value}`; | ||
} |
@@ -25,1 +25,2 @@ export declare function isObject(value: any): boolean; | ||
export declare function loadJSON(url: string): Promise<any>; | ||
export declare function updateQueryStringParameter(url: string, key: string, value: string): string; |
74047
2234