whatwg-url
An implementation of the WHATWG URL Standard's URL API and parsing machinery
Last updated 3 years ago by domenic .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install whatwg-url 
SYNC missed versions from official npm registry.

# whatwg-url

whatwg-url is a full implementation of the WHATWG URL Standard. It can be used standalone, but it also exposes a lot of the internal algorithms that are useful for integrating a URL parser into a project like jsdom.

Specification conformance

whatwg-url is currently up to date with the URL spec up to commit eee49fd.

For file: URLs, whose origin is left unspecified, whatwg-url chooses to use a new opaque origin (which serializes to "null").

whatwg-url does not yet implement any encoding handling beyond UTF-8. That is, the encoding override parameter does not exist in our API.

API

The URL and URLSearchParams classes

The main API is provided by the URL and URLSearchParams exports, which follows the spec's behavior in all ways (including e.g. USVString conversion). Most consumers of this library will want to use these.

Low-level URL Standard API

The following methods are exported for use by places like jsdom that need to implement things like HTMLHyperlinkElementUtils. They mostly operate on or return an "internal URL" or "URL record" type.

The stateOverride parameter is one of the following strings:

The URL record type has the following API:

These properties should be treated with care, as in general changing them will cause the URL record to be in an inconsistent state until the appropriate invocation of basicURLParse is used to fix it up. You can see examples of this in the URL Standard, where there are many step sequences like "4. Set context object’s url’s fragment to the empty string. 5. Basic URL parse input with context object’s url as url and fragment state as state override." In between those two steps, a URL record is in an unusable state.

The return value of "failure" in the spec is represented by null. That is, functions like parseURL and basicURLParse can return either a URL record or null.

whatwg-url/webidl2js-wrapper module

This module exports the URL and URLSearchParams interface wrappers API generated by webidl2js.

Development instructions

First, install Node.js. Then, fetch the dependencies of whatwg-url, by running from this directory:

npm install

To run tests:

npm test

To generate a coverage report:

npm run coverage

To build and run the live viewer:

npm run prepare
npm run build-live-viewer

Serve the contents of the live-viewer directory using any web server.

Supporting whatwg-url

The jsdom project (including whatwg-url) is a community-driven project maintained by a team of volunteers. You could support us by:

  • Getting professional support for whatwg-url as part of a Tidelift subscription. Tidelift helps making open source sustainable for us while giving teams assurances for maintenance, licensing, and security.
  • Contributing directly to the project.

Current Tags

  • 14.0.0                                ...           latest (a year ago)

63 Versions

  • 14.0.0                                ...           a year ago
  • 13.0.0                                ...           a year ago
  • 12.0.1                                ...           2 years ago
  • 12.0.0                                ...           2 years ago
  • 11.0.0                                ...           3 years ago
  • 10.0.0                                ...           3 years ago
  • 9.1.0                                ...           3 years ago
  • 9.0.0                                ...           3 years ago
  • 8.7.0                                ...           3 years ago
  • 8.6.0                                ...           3 years ago
  • 8.5.0                                ...           4 years ago
  • 8.4.0                                ...           4 years ago
  • 8.3.0                                ...           4 years ago
  • 8.2.2                                ...           4 years ago
  • 8.2.1                                ...           4 years ago
  • 8.2.0                                ...           4 years ago
  • 8.1.0                                ...           5 years ago
  • 8.0.0                                ...           5 years ago
  • 7.1.0                                ...           5 years ago
  • 7.0.0                                ...           6 years ago
  • 6.5.0                                ...           6 years ago
  • 6.4.1                                ...           7 years ago
  • 6.4.0                                ...           7 years ago
  • 6.3.0                                ...           7 years ago
  • 6.2.1                                ...           7 years ago
  • 6.2.0                                ...           7 years ago
  • 6.1.0                                ...           7 years ago
  • 6.0.1                                ...           7 years ago
  • 6.0.0                                ...           7 years ago
  • 5.0.0                                ...           7 years ago
  • 4.8.0                                ...           8 years ago
  • 4.7.1                                ...           8 years ago
  • 4.7.0                                ...           8 years ago
  • 4.6.0                                ...           8 years ago
  • 4.5.1                                ...           8 years ago
  • 4.5.0                                ...           8 years ago
  • 4.4.0                                ...           8 years ago
  • 4.3.0                                ...           8 years ago
  • 4.2.0                                ...           8 years ago
  • 4.1.1                                ...           8 years ago
  • 4.1.0                                ...           8 years ago
  • 4.0.0                                ...           8 years ago
  • 3.1.0                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.6.5                                ...           9 years ago
  • 0.6.4                                ...           9 years ago
  • 0.6.2                                ...           9 years ago
  • 0.6.1                                ...           9 years ago
  • 0.6.0                                ...           9 years ago
  • 0.5.0                                ...           9 years ago
  • 0.4.2                                ...           9 years ago
  • 0.4.1                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.1                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.1                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Downloads
Total 4
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (8)

© 2010 - cnpmjs.org x YWFE | Home | YWFE