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

@1001-digital/normalize-dweb-url

v0.1.0

Published

Normalize IPFS, IPNS, and Arweave URIs — gateway detection, redundant path removal, raw CID handling.

Readme

@1001-digital/normalize-dweb-url

Normalize IPFS, IPNS, and Arweave URIs -- gateway detection, redundant path removal, raw CID handling.

npm install @1001-digital/normalize-dweb-url

Usage

import { normalizeUri, isResolvableUri } from '@1001-digital/normalize-dweb-url'

normalizeUri('https://gateway.pinata.cloud/ipfs/QmXxx')  // 'ipfs://QmXxx'
normalizeUri('https://bafyABC.ipfs.nftstorage.link')     // 'ipfs://bafyABC'
normalizeUri('https://arweave.net/txId123')               // 'ar://txId123'
normalizeUri('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG')
// 'ipfs://QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG'

isResolvableUri('ipfs://QmXxx')  // true
isResolvableUri('ar://txId123')  // true
isResolvableUri('hello world')   // false

normalizeUri(uri: string): string

Converts gateway URLs and raw CIDs into their canonical protocol form.

| Input | Output | | --- | --- | | https://ipfs.io/ipfs/QmXxx | ipfs://QmXxx | | https://bafyABC.ipfs.w3s.link/meta.json | ipfs://bafyABC/meta.json | | https://ipfs.io/ipns/example.eth | ipns://example.eth | | https://arweave.net/txId123 | ar://txId123 | | ipfs://ipfs/QmXxx | ipfs://QmXxx | | ipfs://https://gateway.pinata.cloud/ipfs/QmXxx | ipfs://QmXxx | | QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG | ipfs://QmYwAPJzv5... | | data:application/json;base64,... | passed through | | https://example.com/image.png | passed through |

Handles:

  • Path-based IPFS/IPNS gateways (/ipfs/..., /ipns/...)
  • Subdomain IPFS/IPNS gateways (*.ipfs.nftstorage.link, *.ipns.dweb.link, etc.)
  • Arweave gateways (arweave.net, ar-io.dev, ar-io.net, arweave.dev)
  • Redundant path segments (ipfs://ipfs/Qm... -> ipfs://Qm...)
  • Embedded gateway URLs (ipfs://https://gateway.pinata.cloud/ipfs/Qm...)
  • Raw CIDv0 (Qm...) and CIDv1 (bafy...) strings
  • Whitespace trimming

isResolvableUri(value: unknown): value is string

Type guard that returns true when the value is a string that looks like a resolvable URI: ipfs://, ipns://, ar://, http(s)://, data:, or a raw CID.

Rejects non-strings, strings shorter than 5 characters, and non-data: URIs longer than 2048 characters.

License

MIT