chore: split web op crate (#9635)
This commit starts splitting out the deno_web op crate into multiple
smaller crates. This commit splits out WebIDL and URL API, but in the
future I want to split out each spec into its own crate. That means we
will have (in rough order of loading): `webidl`, `dom`, `streams`,
`console`, `encoding`, `url`, `file`, `fetch`, `websocket`, and
`webgpu` crates.
2021-03-12 10:17:18 -05:00
|
|
|
# deno_url
|
|
|
|
|
2024-06-17 18:07:48 -04:00
|
|
|
**This crate implements the URL, and URLPattern APIs for Deno.**
|
chore: split web op crate (#9635)
This commit starts splitting out the deno_web op crate into multiple
smaller crates. This commit splits out WebIDL and URL API, but in the
future I want to split out each spec into its own crate. That means we
will have (in rough order of loading): `webidl`, `dom`, `streams`,
`console`, `encoding`, `url`, `file`, `fetch`, `websocket`, and
`webgpu` crates.
2021-03-12 10:17:18 -05:00
|
|
|
|
2021-09-08 05:14:29 -04:00
|
|
|
URL Spec: https://url.spec.whatwg.org/ URLPattern Spec:
|
|
|
|
https://wicg.github.io/urlpattern/
|
2024-06-17 18:07:48 -04:00
|
|
|
|
|
|
|
## Usage Example
|
|
|
|
|
|
|
|
From javascript, include the extension's source, and assign `URL`, `URLPattern`,
|
|
|
|
and `URLSearchParams` to the global scope:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
import * as url from "ext:deno_url/00_url.js";
|
|
|
|
import * as urlPattern from "ext:deno_url/01_urlpattern.js";
|
|
|
|
|
|
|
|
Object.defineProperty(globalThis, "URL", {
|
|
|
|
value: url.URL,
|
|
|
|
enumerable: false,
|
|
|
|
configurable: true,
|
|
|
|
writable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
Object.defineProperty(globalThis, "URLPattern", {
|
|
|
|
value: url.URLPattern,
|
|
|
|
enumerable: false,
|
|
|
|
configurable: true,
|
|
|
|
writable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
Object.defineProperty(globalThis, "URLSearchParams", {
|
|
|
|
value: url.URLSearchParams,
|
|
|
|
enumerable: false,
|
|
|
|
configurable: true,
|
|
|
|
writable: true,
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
Then from rust, provide `deno_url::deno_url::init_ops_and_esm()` in the
|
|
|
|
`extensions` field of your `RuntimeOptions`
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
- **deno_webidl**: Provided by the `deno_webidl` crate
|
|
|
|
|
|
|
|
## Provided ops
|
|
|
|
|
|
|
|
Following ops are provided, which can be accessed through `Deno.ops`:
|
|
|
|
|
|
|
|
- op_url_reparse
|
|
|
|
- op_url_parse
|
|
|
|
- op_url_get_serialization
|
|
|
|
- op_url_parse_with_base
|
|
|
|
- op_url_parse_search_params
|
|
|
|
- op_url_stringify_search_params
|
|
|
|
- op_urlpattern_parse
|
|
|
|
- op_urlpattern_process_match_input
|