bare-url
Reference for bare-url: a WHATWG URL and URLSearchParams implementation for Bare, with file-URL helpers.
bare-url is a WHATWG URL implementation for Bare, matching the standard URL and URLSearchParams web APIs plus Node-style file-URL helpers. It's a native addon.
npm i bare-urlUsage
const { URL, URLSearchParams } = require('bare-url')
const url = new URL('https://example.com/path?foo=bar#hash')
console.log(url.hostname) // 'example.com'
console.log(url.searchParams.get('foo')) // 'bar'API
URL
const url = new URL(input[, base])
Parse a URL. Exposes the standard components: href, protocol, username, password, host, hostname, port, pathname, search, searchParams, hash, and toString() / toJSON().
Statics
URL.parse(input[, base]), URL.canParse(input[, base]), URL.isURL(value), URL.format(parts), and the file-URL helpers URL.fileURLToPath(url) and URL.pathToFileURL(pathname).
URLSearchParams
const params = new URLSearchParams([init])
A query-string map: size, append(name, value), delete(name[, value]), get(name), getAll(name), has(name[, value]), set(name, value), toString(), toJSON(), and URLSearchParams.isURLSearchParams(value).
Related modules
Builds on bare-path (see Bare modules).
See also
bare-fetch—accepts theseURLobjects as request input.- Bare modules—the full
bare-*catalog. - Bare runtime API—the runtime this runs on.