Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsenv/utils

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/utils - npm Package Compare versions

Comparing version 1.7.2 to 1.7.3

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc