jsdom/whatwg-url hiện có 420 sao trên GitHub, viết chủ yếu bằng JavaScript. An implementation of the WHATWG URL Standard in JavaScript
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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 fde3f74.
For file: URLs, whose origin is left unspecified, whatwg-url chooses to use a new opaque origin (which serializes to "null").
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.
Percent decode a string: percentDecodeString(string)
The stateOverride parameter is one of the following strings:
"scheme start"
"scheme"
"no scheme"
"special relative or authority"
"path or authority"
"relative"
"relative slash"
"special authority slashes"
"special authority ignore slashes"
"authority"
"host"
"hostname"
"port"
"file"
"file slash"
"file host"
"path start"
"path"
"opaque path"
"query"
"fragment"
The URL record type has the following API:
scheme
username
password
host
port
path (as an array of strings, or a string)
query
fragment
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 ornull.
The parseURLWithValidationErrors function returns an object with a url property and a validationErrors property. The url property is a URL record or null, and the validationErrors property is an array of validation error names reported while parsing.
The isValidURLString function implements the grammar-based validity checker from the URL Standard's URL writing section. This is separate from parser validation errors, so it can disagree with parseURLWithValidationErrors() in some cases. Pass a baseURL URL record to check relative-URL strings.
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.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/jsdom/whatwg-url là nguồn chính thức.
jsdom/whatwg-url có phải mã nguồn mở không?
Có — jsdom/whatwg-url phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/jsdom/whatwg-url.
jsdom/whatwg-url là gì?
jsdom/whatwg-url (jsdom/whatwg-url) là dự án JavaScript trên GitHub. Theo mô tả gốc: An implementation of the WHATWG URL Standard in JavaScript
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về whatwg-url?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về whatwg-url.