Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

An implementation of the WHATWG URL Standard in JavaScript

License

NotificationsYou must be signed in to change notification settings

jsdom/whatwg-url

Repository files navigation

whatwg-url is a full implementation of the WHATWGURL 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 likejsdom.

Specification conformance

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

Forfile: URLs, whoseorigin 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, theencoding override parameter does not exist in our API.

API

TheURL andURLSearchParams classes

The main API is provided by theURL andURLSearchParams 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 likeHTMLHyperlinkElementUtils. They mostly operate on or return an "internal URL" or"URL record" type.

ThestateOverride 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 ofbasicURLParse 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 parseinput with context object’s url asurl and fragment state asstate override." In between those two steps, a URL record is in an unusable state.

The return value of "failure" in the spec is represented bynull. That is, functions likeparseURL andbasicURLParse can returneither a URL recordornull.

whatwg-url/webidl2js-wrapper module

This module exports theURL andURLSearchParamsinterface wrappers API generated bywebidl2js.

Development instructions

First, installNode.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 preparenpm run build-live-viewer

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

Supporting whatwg-url

The jsdom project (including whatwg-url) is a community-driven project maintained by a team ofvolunteers. 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.

[8]ページ先頭

©2009-2025 Movatter.jp