npm.io
13.1.1 • Published 1 week ago

@verdaccio/url

Licence
MIT
Version
13.1.1
Deps
3
Size
33 kB
Vulns
0
Weekly
0
Stars
17.8K

@verdaccio/url - Verdaccio URL Utilities

Verdaccio Home MIT License Verdaccio Latest This Package Latest

Documentation Discord Bluesky Backers Sponsors

Verdaccio Downloads Docker Pulls GitHub Stars

Note: This package is mostly for internal use by Verdaccio and is only intended to be used with Verdaccio 6.x.

Overview

The @verdaccio/url package provides URL validation, manipulation, and protocol detection utilities for the Verdaccio registry. It handles public URL generation, proxy header parsing, and URL prefix normalization.

Installation

npm install @verdaccio/url

Usage

import {
  combineBaseUrl,
  getPublicUrl,
  getWebProtocol,
  isHost,
  isURLhasValidProtocol,
  validateURL,
  wrapPrefix,
} from '@verdaccio/url';

// Get the public URL for the registry
const publicUrl = getPublicUrl('/verdaccio/', requestOptions);

// Validate URL protocol
isURLhasValidProtocol('https://registry.npmjs.org/'); // true

// Combine base URL components
const baseUrl = combineBaseUrl('https', 'localhost:4873', '/prefix/');
API
  • getPublicUrl(urlPrefix, requestOptions) - Gets public URL from environment variable VERDACCIO_PUBLIC_URL or request headers
  • isURLhasValidProtocol(uri) - Checks if URL starts with http://, https://, or //
  • isHost(url, options) - Validates if a string is a valid host
  • getWebProtocol(headerProtocol, protocol) - Detects running protocol from headers (supports HAProxy)
  • wrapPrefix(prefix) - Normalizes URL prefix to /prefix/ format
  • combineBaseUrl(protocol, host, prefix) - Creates full base registry URL
  • validateURL(publicUrl) - Validates a full URL with protocol

Donations

Verdaccio is run by volunteers; nobody is working full-time on it. If you find this project to be useful and would like to support its development, consider making a donation - your logo might end up in this readme.

Donate starting from $1/month or just one single contribution.

Report a vulnerability

If you want to report a security vulnerability, please follow the steps which we have defined for you in our security policy.

Open Collective Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

sponsor sponsor sponsor sponsor sponsor sponsor sponsor sponsor sponsor sponsor

Open Collective Backers

Thank you to all our backers! [Become a backer]

backers

Special Thanks

Thanks to the following companies to help us to achieve our goals providing free open source licenses.

jetbrains crowdin

Contributors

This project exists thanks to all the people who contribute. [Contribute].

contributors

FAQ / Contact / Troubleshoot

If you have any issue you can try the following options. Do not hesitate to ask or check our issues database. Perhaps someone has asked already what you are looking for.

License

Verdaccio is MIT licensed

The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch files within the /assets folder) are Creative Commons licensed.

Keywords