@lonr/href
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

@lonr/href

The @lonr/href package exports a RelativeURL Class, a URL-like API that helps you resolve relative URLs

Usage

Install href:

# npm
npm install @lonr/href
# yarn
yarn add @lonr/href

Usage:

import { RelativeURL } from "@lonr/href";
// ⛔️ Don't use RelativeURL to parse complete URLs. Use the built-in URL instead
new RelativeURL("https://example.com").pathname === "https://example.com";

new RelativeURL("path/to/file1?q=1").searchParams.set("q", "2");
new RelativeURL("file2", "path/to/file1").pathname === "path/to/file2";
new RelativeURL("file2", "path/to/").pathname === "path/to/file2";
new RelativeURL("../../file2").pathname === "../../file2";

Supported properties: href, pathname, search, searchPrams, hash

Credits

This package is based on the work of jsdom/whatwg-url

Package Sidebar

Install

npm i @lonr/href

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

23.2 kB

Total Files

12

Last publish

Collaborators

  • lonr