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

@xesam/url

v0.1.4

Published

URL-like string splitter for constrained runtimes (zero-dep, RegExp-based).

Readme

@xesam/url

Split URL-like strings in constrained JavaScript runtimes with ES5 + RegExp.

This package is designed for environments such as mini-program runtimes where you may not have a reliable built-in URL object and do not want to depend on third-party parser behavior.

@xesam/url is not a standards-compliant URL parser. It is a tiny splitter for a narrow set of supported input shapes.

npm install @xesam/url

Supported input shapes

  • scheme://[auth@]host[:port][/path][?query][#hash]
  • /path[?query][#hash]

?query-only and #hash-only are documented boundary cases: ?query-only returns populated search and query fields, and #hash-only returns a populated hash field.

Unsupported input classes

  • non-authority scheme URIs such as mailto:[email protected]
  • non-authority payload schemes such as data:text/plain,hello
  • script-like schemes such as javascript:alert(1)
  • protocol-relative URLs such as //example.com/path

Non-goals / not provided

  • RFC / WHATWG compatibility guarantees
  • validation, normalization, decoding, or formatting

Result contract

Every call returns the same stable object shape with these fields:

  • protocol
  • auth
  • host
  • hostname
  • port
  • pathname
  • search
  • query
  • hash

Supported input shapes and documented boundary cases always return the stable object shape above, with populated fields determined by the matched shape or documented boundary rule. Unsupported input classes are non-throwing, but any returned field values are not part of the contract.

Malformed, blank (empty or whitespace-only), nullish, or unmatched inputs collapse to the fixed all-undefined result shape.

Usage

const url = require('@xesam/url');

console.log(url('https://admin:[email protected]:443/path/to/view?tab=home#top'));
console.log(url('miniapp://page.example/path/to/view?tab=home#top'));
console.log(url('/pages/home/index?tab=home#top'));
console.log(url('?query-only'));
console.log(url('#hash-only'));
console.log(url('????'));

Output:

For https://admin:[email protected]:443/path/to/view?tab=home#top:

{
    protocol: 'https:',
    auth: 'admin:root',
    host: 'page.example:443',
    hostname: 'page.example',
    port: '443',
    pathname: '/path/to/view',
    search: '?tab=home',
    query: 'tab=home',
    hash: '#top'
}

For miniapp://page.example/path/to/view?tab=home#top:

{
    protocol: 'miniapp:',
    auth: undefined,
    host: 'page.example',
    hostname: 'page.example',
    port: undefined,
    pathname: '/path/to/view',
    search: '?tab=home',
    query: 'tab=home',
    hash: '#top'
}

For /pages/home/index?tab=home#top:

{
    protocol: undefined,
    auth: undefined,
    host: undefined,
    hostname: undefined,
    port: undefined,
    pathname: '/pages/home/index',
    search: '?tab=home',
    query: 'tab=home',
    hash: '#top'
}

For ?query-only:

{
    protocol: undefined,
    auth: undefined,
    host: undefined,
    hostname: undefined,
    port: undefined,
    pathname: undefined,
    search: '?query-only',
    query: 'query-only',
    hash: undefined
}

For #hash-only:

{
    protocol: undefined,
    auth: undefined,
    host: undefined,
    hostname: undefined,
    port: undefined,
    pathname: undefined,
    search: undefined,
    query: undefined,
    hash: '#hash-only'
}

For ????:

{
    protocol: undefined,
    auth: undefined,
    host: undefined,
    hostname: undefined,
    port: undefined,
    pathname: undefined,
    search: undefined,
    query: undefined,
    hash: undefined
}