@jsenv/utils
Advanced tools
Comparing version 1.7.2 to 1.7.3
{ | ||
"name": "@jsenv/utils", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -19,2 +19,18 @@ import { urlToOrigin, urlToExtension, urlToRessource } from "@jsenv/filesystem" | ||
// normalize url search params: | ||
// Using URLSearchParams to alter the url search params | ||
// can result into "file:///file.css?css_module" | ||
// becoming "file:///file.css?css_module=" | ||
// we want to get rid of the "=" and consider it's the same url | ||
export const normalizeUrl = (url) => { | ||
if (url.includes("?")) { | ||
// disable on data urls (would mess up base64 encoding) | ||
if (url.startsWith("data:")) { | ||
return url | ||
} | ||
return url.replace(/[=](?=&|$)/g, "") | ||
} | ||
return url | ||
} | ||
export const injectQueryParamsIntoSpecifier = (specifier, params) => { | ||
@@ -31,3 +47,3 @@ if (isValidUrl(specifier)) { | ||
if (paramsString) { | ||
return `${beforeQuestion}?${paramsString.replace(/[=](?=&|$)/g, "")}` | ||
return `${beforeQuestion}?${paramsString}` | ||
} | ||
@@ -43,7 +59,3 @@ return specifier | ||
const urlWithParams = urlObject.href | ||
// injectQueryParams('http://example.com/file.js', { hmr: '' }) | ||
// returns | ||
// "http://example.com/file.js?hmr=" | ||
// It is technically valid but "=" signs hurts readability | ||
return urlWithParams.replace(/[=](?=&|$)/g, "") | ||
return urlWithParams | ||
} | ||
@@ -50,0 +62,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204051
6054