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

@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.4.1 to 2.5.0

src/yield_ancestor_urls.js

4

package.json
{
"name": "@jsenv/urls",
"version": "2.4.1",
"version": "2.5.0",
"license": "MIT",

@@ -31,4 +31,4 @@ "repository": {

"dependencies": {
"@jsenv/humanize": "1.2.6"
"@jsenv/humanize": "1.2.7"
}
}

@@ -14,4 +14,5 @@ // tslint:disable:ordered-imports

renderUrlOrRelativeUrlFilename,
setUrlFilename,
setUrlBasename,
setUrlExtension,
setUrlFilename,
ensurePathnameTrailingSlash,

@@ -46,1 +47,3 @@ removePathnameTrailingSlash,

export { getCommonPathname } from "./common_pathname.js";
export { yieldAncestorUrls } from "./yield_ancestor_urls.js";

@@ -5,2 +5,6 @@ import { urlToFilename } from "./url_to_filename.js";

const filename = urlToFilename(url);
return filenameToBasename(filename);
};
export const filenameToBasename = (filename) => {
const dotLastIndex = filename.lastIndexOf(".");

@@ -7,0 +11,0 @@ const basename =

@@ -5,2 +5,6 @@ import { urlToPathname } from "./url_to_pathname.js";

const pathname = urlToPathname(url);
return pathnameToFilename(pathname);
};
export const pathnameToFilename = (pathname) => {
const pathnameBeforeLastSlash = pathname.endsWith("/")

@@ -7,0 +11,0 @@ ? pathname.slice(0, -1)

@@ -0,2 +1,4 @@

import { filenameToBasename } from "./url_to_basename.js";
import { urlToExtension } from "./url_to_extension.js";
import { pathnameToFilename } from "./url_to_filename.js";
import { urlToOrigin } from "./url_to_origin.js";

@@ -142,2 +144,5 @@ import { urlToResource } from "./url_to_resource.js";

const currentExtension = urlToExtension(url);
if (typeof extension === "function") {
extension = extension(currentExtension);
}
const resource = urlToResource(url);

@@ -161,12 +166,20 @@ const [pathname, search] = resource.split("?");

export const setUrlFilename = (url, filename) => {
const urlObject = new URL(url);
let { origin, search, hash } = urlObject;
// origin is "null" for "file://" urls with Node.js
if (origin === "null" && urlObject.href.startsWith("file:")) {
origin = "file://";
}
const parentPathname = new URL("./", urlObject).pathname;
return `${origin}${parentPathname}${filename}${search}${hash}`;
const parentPathname = new URL("./", url).pathname;
return transformUrlPathname(url, (pathname) => {
if (typeof filename === "function") {
filename = filename(pathnameToFilename(pathname));
}
return `${parentPathname}${filename}`;
});
};
export const setUrlBasename = (url, basename) => {
return setUrlFilename(url, (filename) => {
if (typeof basename === "function") {
basename = basename(filenameToBasename(filename));
}
return `${basename}${urlToExtension(url)}`;
});
};
const transformUrlPathname = (url, transformer) => {

@@ -173,0 +186,0 @@ if (typeof url === "string") {

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