Skip to content

Repository files navigation

@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 insteadnewRelativeURL("https://example.com").pathname==="https://example.com";newRelativeURL("path/to/file1?q=1").searchParams.set("q","2");newRelativeURL("file2","path/to/file1").pathname==="path/to/file2";newRelativeURL("file2","path/to/").pathname==="path/to/file2";newRelativeURL("../../file2").pathname==="../../file2";

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

Credits

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

About

Provides a URL-like API that helps you resolve relative URLs

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages