Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Node.js path API but for URLs. Works on all runtimes and platforms.
All functions accept both a url string or a native URL object and always return a URL object wherever possible.
Return the last portion of a url.
import { basename } from "pathurl";
basename("https://deno.land/std/assert/mod.ts"); // "mod.ts"
basename("https://deno.land/"); // "deno.land"
Return the parent directory url of a url path.
import { dirname } from "pathurl";
dirname("https://deno.land/std/assert/mod.ts");
// "https://deno.land/std/assert"
Return the extension of a url.
import { extname } from "pathurl";
extname("https://deno.land/std/assert/mod.ts"); // ".ts"
extname("https://deno.land/") // ".land"
Generate a url from ParsedURL
object.
import { format } from "pathurl";
format({
dir: "https://deno.land/std/assert",
base: "mod.ts"
}); // "https://deno.land/std/assert/mod.ts"
Join all given a sequence of url and paths, then normalizes the resulting url.
import { join } from "pathurl";
join("https://deno.land", "std", "assert", "mod.ts");
// "https://deno.land/std/assert/mod.ts"
Normalize a url, resolving '..'
and '.'
segments and extra '/'
s (if any).
import { normalize } from "pathurl";
normalize("https://deno.land/std/assert//../async/retry.ts/");
// "https://deno.land/std/async/retry.ts/"
Return a ParsedURL
object of the url.
import { parse } from "pathurl";
parse("https://deno.land/std/assert/mod.ts");
// {
// dir: "https://deno.land/std/assert",
// root: "https://deno.land",
// base: "mod.ts",
// name: "mod",
// ext: ".ts"
// }
Return the relative url from from
to to
based on from
as base url.
import { relative } from "pathurl";
relative("https://deno.land/std/assert/mod.ts", "./equal.ts");
// "https://deno.land/std/assert/equal.ts"
Resolve url and path segments into an absolute url.
import { resolve } from "pathurl";
resolve("https://deno.land", "std", "assert", "mod.ts", "../assert.ts");
// "https://deno.land/std/assert/assert.ts"
Strips any hash (eg. #header
) or search parameters (eg. ?foo=bar
) from the provided URL.
(Mutates the original url provided)
import { strip } from "pathurl";
const url = new URL("https://deno.land/std/assert/mod.ts?foo=bar#header");
strip(url);
// url is now "https://deno.land/std/assert/mod.ts"
Clone this repository.
Run tests and ensure that all pass along with 100% code coverage.
bun test --coverage
Build the module and output in ./dist
folder.
bun run build
This repository uses MIT license. See LICENSE for full license text.
FAQs
Node.js path API but for URLs. Works everywhere.
The npm package pathurl receives a total of 0 weekly downloads. As such, pathurl popularity was classified as not popular.
We found that pathurl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.