Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

whatwg-url

Package Overview
Dependencies
2
Maintainers
6
Versions
59
Issues
File Explorer

Advanced tools

whatwg-url

An implementation of the WHATWG URL Standard's URL API and parsing machinery

    11.0.0latest

Version published
Maintainers
6
Weekly downloads
46,704,290
decreased by-9.71%

Weekly downloads

Changelog

Source

11.0.0

The breaking changes in this release are only to the Low-level URL Standard API. No actual URL parsing or serialization behavior has changed, and users of the URL and URLSearchParams exports are not affected.

These changes follow https://github.com/whatwg/url/commit/fbaa03cb19ee5718953f5f6d179e0339e31f1ede.

  • Removed the URL record type's cannotBeABaseURL property.
  • Changed the URL record type's path from always being an array of strings, to being either a single string or an array of strings.
  • Renamed the "cannot-be-a-base-URL path" parser state (i.e. value for stateOverride) to "opaque path".
  • Added the serializePath(urlRecord) export.
  • Added the hasAnOpaquePath(urlRecord) export.

Readme

Source

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 43c2713.

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.

FAQs

What is whatwg-url?

An implementation of the WHATWG URL Standard's URL API and parsing machinery

Is whatwg-url popular?

The npm package whatwg-url receives a total of 36,068,601 weekly downloads. As such, whatwg-url popularity was classified as popular.

Is whatwg-url well maintained?

We found that whatwg-url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 6 open source maintainers collaborating on the project.

Last updated on 19 Oct 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc