npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@knide/pathnorm

v1.0.4

Published

Normalize and join path and URL segments. Supports URLs, POSIX paths, Win32 drive letters, UNC, and namespace paths.

Readme

@knide/pathnorm

npm version Bundle Size License

Normalize and join path or URL segments into a single clean string.

  • Zero dependencies
  • Full TypeScript support
  • Tree-shakeable
  • < 500B minified + gzipped — use @knide/pathnorm/posix for an even lighter bundle in browser-only contexts

Installation

npm install @knide/pathnorm
# or
yarn add @knide/pathnorm
# or
pnpm add @knide/pathnorm

Two Entry Points

| Import | Win32 | UNC | Namespace | URLs | POSIX | |-------------------------|-------|-----|-----------|------|-------| | @knide/pathnorm | ✅ | ✅ | ✅ | ✅ | ✅ |
| @knide/pathnorm/posix | ❌ | ❌ | ❌ | ✅ | ✅ |

Use @knide/pathnorm/posix in browser or web server contexts where Win32 paths will never appear — it's lighter and purpose-built for URLs and POSIX paths.


@knide/pathnorm

Exports np and unixNp.

import { np, unixNp } from '@knide/pathnorm'

np(...parts) (POSIX + Win32 + UNC + URLs)

Joins and normalizes path or URL segments. Detects and handles URLs, POSIX paths, Win32 drive letters, UNC paths, and Win32 namespace paths automatically.

import { np } from '@knide/pathnorm'

// URLs
np("https://example.com//api/", "v1//users", "profile")
// → "https://example.com/api/v1/users/profile"

np("exp://com.myapp//screens/", "home")
// → "exp://com.myapp/screens/home"

// POSIX
np("/var/www//html/", "assets//images", "logo.png")
// → "/var/www/html/assets/images/logo.png"

np("uploads//images", "/photos")
// → "/uploads/images/photos"

// Win32 drive letter
np("C:\\Users\\\\Alice\\Documents", "report.pdf")
// → "C:\Users\Alice\Documents\report.pdf"

// UNC
np("\\\\server01\\share\\\\docs", "letter.txt")
// → "//server01/share/docs/letter.txt"

// Win32 namespace
np("\\\\?\\C:\\Users\\\\Alice", "report.pdf")
// → "//?/C:/Users/Alice/report.pdf"

// Mixed slashes
np("C:\\projects//my-app\\\\src")
// → "C:\projects\my-app\src"

unixNp(...parts) (always forward slashes)

Like np, but always returns a Unix-style path with forward slashes. Useful when working with Win32 paths in a Unix-expecting context.

import { unixNp } from '@knide/pathnorm'

unixNp("C:\\Users\\\\Alice\\Documents", "report.pdf")
// → "C:/Users/Alice/Documents/report.pdf"

unixNp("\\\\server01\\share\\\\docs", "letter.txt")
// → "//server01/share/docs/letter.txt"

unixNp("\\\\?\\C:\\Users\\\\Alice", "report.pdf")
// → "//?/C:/Users/Alice/report.pdf"

unixNp("/var/www//html", "index.html")
// → "/var/www/html/index.html"

@knide/pathnorm/posix

Exports np. No Win32 support — ideal for browser and web server environments.

import { np } from '@knide/pathnorm/posix'

np(...parts) (POSIX + URLs)

import { np } from '@knide/pathnorm/posix'

// URLs
np("https://example.com//api/", "v1//users", "profile")
// → "https://example.com/api/v1/users/profile"

np("exp://com.myapp//screens/", "home")
// → "exp://com.myapp/screens/home"

// POSIX
np("/var/www//html/", "assets//images", "logo.png")
// → "/var/www/html/assets/images/logo.png"

np("uploads//images", "/photos")
// → "/uploads/images/photos"

// Typical web usage
np(window.location.origin, "/api/proxy//betterauth")
// → "https://myapp.com/api/proxy/betterauth"

Behavior Notes

  • Only the first segment is checked for a URL scheme (://). Subsequent segments that look like URLs are treated as plain path parts.
  • Leading slashes are preserved if any segment introduces one.
  • Consecutive slashes (or backslashes in Win32 mode) are collapsed into one.
  • Trailing slashes are not preserved.
// Only the first segment's scheme is treated as a URL prefix
np("https://example.com//", "/api/v1", "http://users")
// → "https://example.com/api/v1/http:/users"