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

@njkleiner/urls

v1.0.0

Published

A collection of common functions to make working with URLs less painful

Readme

urls Build Status Downloads

A collection of common functions to make working with URLs less painful.

Install

$ npm install @njkleiner/urls

Usage

const urls = require('@njkleiner/urls');

urls.isURL('https://example.com');
// => true

urls.isURL('not a url');
// => false

urls.isAbsolute('https://example.com/about');
// => true

urls.isRelative('/test');
// => true

urls.normalize('EXAMPLE.com');
// => http://example.com/

urls.compare('http://example.com/', 'example.com');
// => true

urls.matchesHost('https://www.example.com/test', 'example.com');
// => true

urls.normalizeQuery('https://www.example.com/?abc=def&xyz=123');
// => {'abc': 'def', 'xyz': '123'}

urls.appendQuery('https://example.com/test?abc=xyz', {'foo': 'bar'});
// => https://example.com/test?abc=xyz&foo=bar

urls.join('https://example.com', '/test');
// => https://example.com/test

API

urls.isURL(value, protocols?)

Returns true if value is a valid URL.

value

Type: string

The string for which to determine whether it is a URL.

protocols

Type: Array<string>
Default: ['http', 'https']

A list of valid protocols.

By default, only http and https are considered valid protocols. If you want to accept any protocol, use an empty array.

urls.isAbsolute(value)

Returns true if value is an absolute URL.

value

Type: string

The URL to test.

urls.isRelative(value)

Returns true if value is a relative URL.

value

Type: string

The URL to test.

urls.normalize(value)

Takes a URL-like string and returns a normalized URL.

Appends http:// if no protocol is specified, normalizes the URL by calling new URL(value).toString() and removes trailing # and ? characters when possible.

value

Type: string

The URL to normalize.

urls.compare(left, right)

Returns true if left and right are valid URLs and are equal after normalizing them.

left

Type: string

The first URL to compare.

right

Type: string

The second URL to compare.

urls.matchesHost(value, host)

Returns true if value is a valid URL and its host is host.

value

Type: string

The URL whoose host to test.

host

Type: string

The host to test against.

urls.normalizeQuery(value)

Returns a dictionary object of query parameters parsed from value.

value

Type: string

The URL whoose query parameters to parse and normalize.

urls.appendQuery(value, query)

Appends query parameters to an existing URL and returns the stringified result.

value

Type: string

The URL to append query parameters to.

query

Type: object

A dictionary of query parameters to append.

urls.join(base, path)

Returns a stringified URL that is the result of appending path to base.

base

Type: string

The base URL to append path to.

path

Type: string

The path segment appended to base.

Contributing

You can contribute to this project by sending patches to [email protected].

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.