Socket
Socket
Sign inDemoInstall

@jsenv/urls

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/urls - npm Package Compare versions

Comparing version 2.2.11 to 2.3.0

2

package.json
{
"name": "@jsenv/urls",
"version": "2.2.11",
"version": "2.3.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -163,14 +163,22 @@ import { urlToOrigin } from "./url_to_origin.js";

export const ensurePathnameTrailingSlash = (url) => {
const urlObject = new URL(url);
const { pathname } = urlObject;
if (pathname.endsWith("/")) {
if (typeof url === "string") {
const urlObject = new URL(url);
const { pathname } = urlObject;
if (pathname.endsWith("/")) {
return url;
}
let { origin } = urlObject;
// origin is "null" for "file://" urls with Node.js
if (origin === "null" && urlObject.href.startsWith("file:")) {
origin = "file://";
}
const { search, hash } = urlObject;
const urlWithTrailingSlash = `${origin}${pathname}/${search}${hash}`;
return urlWithTrailingSlash;
}
if (url.pathname.endsWith("/")) {
return url;
}
let { origin } = urlObject;
// origin is "null" for "file://" urls with Node.js
if (origin === "null" && urlObject.href.startsWith("file:")) {
origin = "file://";
}
const { search, hash } = urlObject;
return `${origin}${pathname}/${search}${hash}`;
url.pathname += "/";
return url;
};

@@ -177,0 +185,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