@i-xi-dev/url
v3.1.23
Published
A JavaScript immutable object that represents the normalized absolute URL.
Downloads
20
Maintainers
Readme
@i-xi-dev/url
A JavaScript immutable object that represents the normalized absolute URL.
Requirement
This module delegates the URL parsing to the URL
.
| Chrome | Edge | Firefox | Safari | Deno | Node.js | | :---: | :---: | :---: | :---: | :---: | :---: | | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Installation
npm
$ npm i @i-xi-dev/[email protected]
import { Uri } from "@i-xi-dev/url";
CDN
Example for UNPKG
import { Uri } from "https://www.unpkg.com/@i-xi-dev/[email protected]/esm/mod.js";
Usage
Uri.Absolute
class
For URL rendering
const url = Uri.Absolute.fromString("http://xn--eckwd4c7cu47r2wf.jp/foo/bar?p1=%E5%80%A41&p2=%E5%80%A42#%E7%B4%A0%E7%89%87");
url.scheme;
// → "http"
url.rawHost;
// → "xn--eckwd4c7cu47r2wf.jp"
url.host;
// → "ドメイン名例.jp"
url.port;
// → 80
url.rawPath;
// → "/foo/bar"
url.path;
// → [ "foo", "bar" ]
url.rawQuery;
// → "p1=%E5%80%A41&p2=%E5%80%A42"
url.query;
// → [ [ "p1", "値1" ], [ "p2", "値2" ] ]
url.rawFragment;
// → "%E7%B4%A0%E7%89%87"
url.fragment;
// → "素片"