@blyou/reurl 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -132
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
# reurl
|
|
2
|
-
|
|
3
|
-
超轻量的 URL 解析器:仅做必要的字符串切分与拼接,不做任何编码 / 解码 / 转义,不做规范化,不解析相对路径。与浏览器原生 `URL` / `URLSearchParams` 的 API 对齐,但运行时代码体积极小(构建产物约 1 KB gzip)。
|
|
4
|
-
|
|
5
|
-
## 特性
|
|
6
|
-
|
|
7
|
-
- 🪶 **极小体积**:仅做必要的字符串切分与拼接,零依赖
|
|
8
|
-
- 🔤 **原样保留**:中文、空格、`%20` 等字符一律不处理,查询串不经 percent 编解码
|
|
9
|
-
- 🌐 **支持 IPv6**:`[2001:db8::1]:8080` 这类主机正确拆分 host / hostname / port
|
|
10
|
-
- 🧩 **TypeScript 类型对齐**:导出 `ReURL` 与 `ReSearchParams`,签名对齐原生接口
|
|
11
|
-
|
|
12
|
-
## 安装
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
pnpm i @blyou/reurl
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## 使用
|
|
19
|
-
|
|
20
|
-
### ReURL
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import { ReURL } from '@blyou/reurl'
|
|
24
|
-
|
|
25
|
-
const u = new ReURL('https://example.com:8080/a/b?x=1&y=2#frag')
|
|
26
|
-
|
|
27
|
-
u.protocol // 'https:'
|
|
28
|
-
u.host // 'example.com:8080'
|
|
29
|
-
u.hostname // 'example.com'
|
|
30
|
-
u.port // '8080'
|
|
31
|
-
u.pathname // '/a/b'
|
|
32
|
-
u.search // '?x=1&y=2'
|
|
33
|
-
u.hash // '#frag'
|
|
34
|
-
u.origin // 'https://example.com:8080'
|
|
35
|
-
u.href // 'https://example.com:8080/a/b?x=1&y=2#frag'
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
所有 getter 都有对应的 setter,修改任一字段都会即时反映到 `href`:
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
u.hostname = 'b.com' // host → 'b.com:8080'
|
|
42
|
-
u.port = '9090' // host → 'b.com:9090'
|
|
43
|
-
u.pathname = '/new' // href 同步更新
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
#### userinfo(username / password)
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
const u2 = new ReURL('https://user:pass@a.com/')
|
|
50
|
-
|
|
51
|
-
u2.username // 'user'
|
|
52
|
-
u2.password // 'pass'
|
|
53
|
-
u2.password = 'new' // href → 'https://user:new@a.com/'
|
|
54
|
-
u2.username = ''
|
|
55
|
-
u2.password = '' // href → 'https://a.com/'(userinfo 整体移除)
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
#### searchParams 双向联动
|
|
59
|
-
|
|
60
|
-
```ts
|
|
61
|
-
const u = new ReURL('https://a.com/p?a=1&b=2')
|
|
62
|
-
const sp = u.searchParams // 同一对象会被缓存
|
|
63
|
-
|
|
64
|
-
sp.append('c', '3')
|
|
65
|
-
u.href // 'https://a.com/p?a=1&b=2&c=3'
|
|
66
|
-
|
|
67
|
-
u.search = 'k=v'
|
|
68
|
-
sp.get('k') // 'v'
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### ReSearchParams
|
|
72
|
-
|
|
73
|
-
查询串仅按 `&` / `=` 切分与拼接,不做编解码。
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
import { ReSearchParams } from '@blyou/reurl'
|
|
77
|
-
|
|
78
|
-
const sp = new ReSearchParams('?a=1&a=2&b=2')
|
|
79
|
-
|
|
80
|
-
sp.get('a') // '1'
|
|
81
|
-
sp.getAll('a') // ['1', '2']
|
|
82
|
-
sp.has('b') // true
|
|
83
|
-
sp.append('c', '3')
|
|
84
|
-
sp.set('b', '9') // 先删后插,不保留键的原始位置
|
|
85
|
-
sp.delete('a')
|
|
86
|
-
sp.sort() // 按键稳定排序
|
|
87
|
-
sp.toString() // 'b=9&c=3'
|
|
88
|
-
|
|
89
|
-
// 迭代器
|
|
90
|
-
for (const [key, value] of sp) {
|
|
91
|
-
/* ... */
|
|
92
|
-
}
|
|
93
|
-
sp.keys()
|
|
94
|
-
sp.values()
|
|
95
|
-
sp.entries()
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
支持字符串 / 二维数组 / 对象 / `ReSearchParams` 多种构造方式:
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
new ReSearchParams([
|
|
102
|
-
['a', '1'],
|
|
103
|
-
['b', '2'],
|
|
104
|
-
])
|
|
105
|
-
new ReSearchParams({ a: '1', b: '2' })
|
|
106
|
-
new ReSearchParams(new ReSearchParams('a=1'))
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## 与原生 API 的有意差异
|
|
110
|
-
|
|
111
|
-
为了在最小体积下工作,`reurl` 刻意省略了一些原生行为:
|
|
112
|
-
|
|
113
|
-
| 项目 | 原生行为 | reurl 行为 |
|
|
114
|
-
| -------------------- | ---------------------------- | ---------------------------------------------- |
|
|
115
|
-
| 非分层协议 | `data:` / `mailto:` 等可解析 | **不支持**,直接抛出 `TypeError` |
|
|
116
|
-
| 相对路径 | `new URL('/p', base)` 可解析 | **不支持** `base` 参数(相对路径视为不可解析) |
|
|
117
|
-
| `searchParams.set()` | 保留键的原始位置 | 先删后插,位置移到末尾 |
|
|
118
|
-
| userinfo | 拆分且 percent 编解码 | 拆分 username / password,但原样保留不编解码 |
|
|
119
|
-
|
|
120
|
-
## 开发
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
pnpm install # 安装依赖
|
|
124
|
-
pnpm test # 运行单元测试
|
|
125
|
-
pnpm typecheck # 类型检查
|
|
126
|
-
pnpm lint # 代码检查
|
|
127
|
-
pnpm build # 构建产物到 dist/
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## License
|
|
131
|
-
|
|
132
|
-
[MIT](./LICENSE)
|
|
1
|
+
# reurl
|
|
2
|
+
|
|
3
|
+
超轻量的 URL 解析器:仅做必要的字符串切分与拼接,不做任何编码 / 解码 / 转义,不做规范化,不解析相对路径。与浏览器原生 `URL` / `URLSearchParams` 的 API 对齐,但运行时代码体积极小(构建产物约 1 KB gzip)。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🪶 **极小体积**:仅做必要的字符串切分与拼接,零依赖
|
|
8
|
+
- 🔤 **原样保留**:中文、空格、`%20` 等字符一律不处理,查询串不经 percent 编解码
|
|
9
|
+
- 🌐 **支持 IPv6**:`[2001:db8::1]:8080` 这类主机正确拆分 host / hostname / port
|
|
10
|
+
- 🧩 **TypeScript 类型对齐**:导出 `ReURL` 与 `ReSearchParams`,签名对齐原生接口
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm i @blyou/reurl
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 使用
|
|
19
|
+
|
|
20
|
+
### ReURL
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { ReURL } from '@blyou/reurl'
|
|
24
|
+
|
|
25
|
+
const u = new ReURL('https://example.com:8080/a/b?x=1&y=2#frag')
|
|
26
|
+
|
|
27
|
+
u.protocol // 'https:'
|
|
28
|
+
u.host // 'example.com:8080'
|
|
29
|
+
u.hostname // 'example.com'
|
|
30
|
+
u.port // '8080'
|
|
31
|
+
u.pathname // '/a/b'
|
|
32
|
+
u.search // '?x=1&y=2'
|
|
33
|
+
u.hash // '#frag'
|
|
34
|
+
u.origin // 'https://example.com:8080'
|
|
35
|
+
u.href // 'https://example.com:8080/a/b?x=1&y=2#frag'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
所有 getter 都有对应的 setter,修改任一字段都会即时反映到 `href`:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
u.hostname = 'b.com' // host → 'b.com:8080'
|
|
42
|
+
u.port = '9090' // host → 'b.com:9090'
|
|
43
|
+
u.pathname = '/new' // href 同步更新
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### userinfo(username / password)
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
const u2 = new ReURL('https://user:pass@a.com/')
|
|
50
|
+
|
|
51
|
+
u2.username // 'user'
|
|
52
|
+
u2.password // 'pass'
|
|
53
|
+
u2.password = 'new' // href → 'https://user:new@a.com/'
|
|
54
|
+
u2.username = ''
|
|
55
|
+
u2.password = '' // href → 'https://a.com/'(userinfo 整体移除)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### searchParams 双向联动
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const u = new ReURL('https://a.com/p?a=1&b=2')
|
|
62
|
+
const sp = u.searchParams // 同一对象会被缓存
|
|
63
|
+
|
|
64
|
+
sp.append('c', '3')
|
|
65
|
+
u.href // 'https://a.com/p?a=1&b=2&c=3'
|
|
66
|
+
|
|
67
|
+
u.search = 'k=v'
|
|
68
|
+
sp.get('k') // 'v'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### ReSearchParams
|
|
72
|
+
|
|
73
|
+
查询串仅按 `&` / `=` 切分与拼接,不做编解码。
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { ReSearchParams } from '@blyou/reurl'
|
|
77
|
+
|
|
78
|
+
const sp = new ReSearchParams('?a=1&a=2&b=2')
|
|
79
|
+
|
|
80
|
+
sp.get('a') // '1'
|
|
81
|
+
sp.getAll('a') // ['1', '2']
|
|
82
|
+
sp.has('b') // true
|
|
83
|
+
sp.append('c', '3')
|
|
84
|
+
sp.set('b', '9') // 先删后插,不保留键的原始位置
|
|
85
|
+
sp.delete('a')
|
|
86
|
+
sp.sort() // 按键稳定排序
|
|
87
|
+
sp.toString() // 'b=9&c=3'
|
|
88
|
+
|
|
89
|
+
// 迭代器
|
|
90
|
+
for (const [key, value] of sp) {
|
|
91
|
+
/* ... */
|
|
92
|
+
}
|
|
93
|
+
sp.keys()
|
|
94
|
+
sp.values()
|
|
95
|
+
sp.entries()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
支持字符串 / 二维数组 / 对象 / `ReSearchParams` 多种构造方式:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
new ReSearchParams([
|
|
102
|
+
['a', '1'],
|
|
103
|
+
['b', '2'],
|
|
104
|
+
])
|
|
105
|
+
new ReSearchParams({ a: '1', b: '2' })
|
|
106
|
+
new ReSearchParams(new ReSearchParams('a=1'))
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 与原生 API 的有意差异
|
|
110
|
+
|
|
111
|
+
为了在最小体积下工作,`reurl` 刻意省略了一些原生行为:
|
|
112
|
+
|
|
113
|
+
| 项目 | 原生行为 | reurl 行为 |
|
|
114
|
+
| -------------------- | ---------------------------- | ---------------------------------------------- |
|
|
115
|
+
| 非分层协议 | `data:` / `mailto:` 等可解析 | **不支持**,直接抛出 `TypeError` |
|
|
116
|
+
| 相对路径 | `new URL('/p', base)` 可解析 | **不支持** `base` 参数(相对路径视为不可解析) |
|
|
117
|
+
| `searchParams.set()` | 保留键的原始位置 | 先删后插,位置移到末尾 |
|
|
118
|
+
| userinfo | 拆分且 percent 编解码 | 拆分 username / password,但原样保留不编解码 |
|
|
119
|
+
|
|
120
|
+
## 开发
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pnpm install # 安装依赖
|
|
124
|
+
pnpm test # 运行单元测试
|
|
125
|
+
pnpm typecheck # 类型检查
|
|
126
|
+
pnpm lint # 代码检查
|
|
127
|
+
pnpm build # 构建产物到 dist/
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
[MIT](./LICENSE)
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{constructor(e){this.href=e}get href(){let{username:e,password:t}=this;return this.t+`//`+(e||t?e+r(`:`,t)+`@`:``)+this.i+this.h+this.o+this.l}set href(e){let t=``+e,r=TypeError(`Invalid URL: `+e);if(!n.test(t))throw r;let i=t.indexOf(`#`);if(~i?(this.l=t.slice(i),t=t.slice(0,i)):this.l=``,i=t.indexOf(`?`),~i?(this.o=t.slice(i),t=t.slice(0,i)):this.o=``,this.t=n.exec(t)[0],t=t.slice(this.t.length),this.i=``,!t.startsWith(`//`))throw r;i=t.indexOf(`/`,2),~i?(this.host=t.slice(2,i),t=t.slice(i)):(this.host=t.slice(2),t=``),this.pathname=t,this.p?.u(this.o)}get protocol(){return this.t}set protocol(e){this.t=n.test(e)?e:e+`:`}get host(){return this.i}set host(e){let t=e.lastIndexOf(`@`);if(~t){let[n,r=``]=e.slice(0,t).split(`:`);this.username=n,this.password=r,e=e.slice(t+1)}else this.username=this.password=``;this.i=e;let n=e.indexOf(`:`,e.lastIndexOf(`]`)+1);~n?(this.R=e.slice(0,n),this.S=e.slice(n+1)):(this.R=e,this.S=``)}get hostname(){return this.R}set hostname(e){this.R=e,this.i=e+r(`:`,this.S)}get port(){return this.S}set port(e){this.i=this.R+r(`:`,this.S=e)}get pathname(){return this.h}set pathname(e){this.h=r(`/`,e)||`/`}get search(){return this.o}set search(e){this.o=r(`?`,e),this.p?.u(this.o)}get hash(){return this.l}set hash(e){this.l=r(`#`,e)}get origin(){return this.i?this.t+`//`+this.i:`null`}get searchParams(){return this.p
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{constructor(e){this.href=e}get href(){let{username:e,password:t}=this;return this.t+`//`+(e||t?e+r(`:`,t)+`@`:``)+this.i+this.h+this.o+this.l}set href(e){let t=``+e,r=TypeError(`Invalid URL: `+e);if(!n.test(t))throw r;let i=t.indexOf(`#`);if(~i?(this.l=t.slice(i),t=t.slice(0,i)):this.l=``,i=t.indexOf(`?`),~i?(this.o=t.slice(i),t=t.slice(0,i)):this.o=``,this.t=n.exec(t)[0],t=t.slice(this.t.length),this.i=``,!t.startsWith(`//`))throw r;i=t.indexOf(`/`,2),~i?(this.host=t.slice(2,i),t=t.slice(i)):(this.host=t.slice(2),t=``),this.pathname=t,this.p?.u(this.o)}get protocol(){return this.t}set protocol(e){this.t=n.test(e)?e:e+`:`}get host(){return this.i}set host(e){let t=e.lastIndexOf(`@`);if(~t){let[n,r=``]=e.slice(0,t).split(`:`);this.username=n,this.password=r,e=e.slice(t+1)}else this.username=this.password=``;this.i=e;let n=e.indexOf(`:`,e.lastIndexOf(`]`)+1);~n?(this.R=e.slice(0,n),this.S=e.slice(n+1)):(this.R=e,this.S=``)}get hostname(){return this.R}set hostname(e){this.R=e,this.i=e+r(`:`,this.S)}get port(){return this.S}set port(e){this.i=this.R+r(`:`,this.S=e)}get pathname(){return this.h}set pathname(e){this.h=r(`/`,e)||`/`}get search(){return this.o}set search(e){this.o=r(`?`,e),this.p?.u(this.o)}get hash(){return this.l}set hash(e){this.l=r(`#`,e)}get origin(){return this.i?this.t+`//`+this.i:`null`}get searchParams(){return this.p||(this.p=new t(this.o),this.p.m=this),this.p}toString(){return this.href}toJSON(){return this.href}},t=class e{_=[];constructor(t){if(t instanceof e&&(t=[...t]),typeof t==`string`)this.u(t);else if(t!=null)for(let[e,n=``]of Array.isArray(t)?t:Object.entries(t))this._.push([e,n])}u(e){if(this._=[],e=e[0]==`?`?e.slice(1):e)for(let t of e.split(`&`)){let[e,n=``]=t.split(`=`);this._.push([e,n])}}M(){this.m&&(this.m.o=`?`+this)}append(e,t){this.M(this._.push([e,t]))}delete(e,t){this.M(this._=this._.filter(n=>n[0]!=e||t!=null&&n[1]!=t))}get(e){return this._.find(t=>t[0]==e)?.[1]??null}getAll(e){return this._.filter(t=>t[0]==e).map(e=>e[1])}has(e,t){return this._.some(n=>n[0]==e&&(t==null||n[1]==t))}set(e,t){this.delete(e),this.append(e,t)}sort(){this.M(this._.sort(([e],[t])=>e<t?-1:+(e>t)))}toString(e){return r(e,this._.map(e=>e.join(`=`)).join(`&`))}*entries(){for(let e of this._)yield e}*keys(){for(let e of this._)yield e[0]}*values(){for(let e of this._)yield e[1]}[Symbol.iterator](){return this.entries()}};const n=/^[a-zA-Z][a-zA-Z\d+.-]*:/,r=(e,t)=>t&&e&&t[0]!=e?e+t:t;exports.ReSearchParams=t,exports.ReURL=e;
|
package/dist/index.d.cts
CHANGED
|
@@ -62,7 +62,7 @@ declare class ReSearchParams {
|
|
|
62
62
|
/** 按键稳定排序 */
|
|
63
63
|
sort(): void;
|
|
64
64
|
/** 仅拼接,不做任何编码 */
|
|
65
|
-
toString(): string;
|
|
65
|
+
toString(pre?: string): string;
|
|
66
66
|
entries(): IterableIterator<[string, string]>;
|
|
67
67
|
keys(): IterableIterator<string>;
|
|
68
68
|
values(): IterableIterator<string>;
|
package/dist/index.d.mts
CHANGED
|
@@ -62,7 +62,7 @@ declare class ReSearchParams {
|
|
|
62
62
|
/** 按键稳定排序 */
|
|
63
63
|
sort(): void;
|
|
64
64
|
/** 仅拼接,不做任何编码 */
|
|
65
|
-
toString(): string;
|
|
65
|
+
toString(pre?: string): string;
|
|
66
66
|
entries(): IterableIterator<[string, string]>;
|
|
67
67
|
keys(): IterableIterator<string>;
|
|
68
68
|
values(): IterableIterator<string>;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class{constructor(e){this.href=e}get href(){let{username:e,password:t}=this;return this.t+`//`+(e||t?e+r(`:`,t)+`@`:``)+this.
|
|
1
|
+
var e=class{constructor(e){this.href=e}get href(){let{username:e,password:t}=this;return this.t+`//`+(e||t?e+r(`:`,t)+`@`:``)+this.h+this.i+this.o+this.l}set href(e){let t=``+e,r=TypeError(`Invalid URL: `+e);if(!n.test(t))throw r;let i=t.indexOf(`#`);if(~i?(this.l=t.slice(i),t=t.slice(0,i)):this.l=``,i=t.indexOf(`?`),~i?(this.o=t.slice(i),t=t.slice(0,i)):this.o=``,this.t=n.exec(t)[0],t=t.slice(this.t.length),this.h=``,!t.startsWith(`//`))throw r;i=t.indexOf(`/`,2),~i?(this.host=t.slice(2,i),t=t.slice(i)):(this.host=t.slice(2),t=``),this.pathname=t,this.p?.u(this.o)}get protocol(){return this.t}set protocol(e){this.t=n.test(e)?e:e+`:`}get host(){return this.h}set host(e){let t=e.lastIndexOf(`@`);if(~t){let[n,r=``]=e.slice(0,t).split(`:`);this.username=n,this.password=r,e=e.slice(t+1)}else this.username=this.password=``;this.h=e;let n=e.indexOf(`:`,e.lastIndexOf(`]`)+1);~n?(this.m=e.slice(0,n),this.A=e.slice(n+1)):(this.m=e,this.A=``)}get hostname(){return this.m}set hostname(e){this.m=e,this.h=e+r(`:`,this.A)}get port(){return this.A}set port(e){this.h=this.m+r(`:`,this.A=e)}get pathname(){return this.i}set pathname(e){this.i=r(`/`,e)||`/`}get search(){return this.o}set search(e){this.o=r(`?`,e),this.p?.u(this.o)}get hash(){return this.l}set hash(e){this.l=r(`#`,e)}get origin(){return this.h?this.t+`//`+this.h:`null`}get searchParams(){return this.p||(this.p=new t(this.o),this.p.S=this),this.p}toString(){return this.href}toJSON(){return this.href}},t=class e{v=[];constructor(t){if(t instanceof e&&(t=[...t]),typeof t==`string`)this.u(t);else if(t!=null)for(let[e,n=``]of Array.isArray(t)?t:Object.entries(t))this.v.push([e,n])}u(e){if(this.v=[],e=e[0]==`?`?e.slice(1):e)for(let t of e.split(`&`)){let[e,n=``]=t.split(`=`);this.v.push([e,n])}}_(){this.S&&(this.S.o=`?`+this)}append(e,t){this._(this.v.push([e,t]))}delete(e,t){this._(this.v=this.v.filter(n=>n[0]!=e||t!=null&&n[1]!=t))}get(e){return this.v.find(t=>t[0]==e)?.[1]??null}getAll(e){return this.v.filter(t=>t[0]==e).map(e=>e[1])}has(e,t){return this.v.some(n=>n[0]==e&&(t==null||n[1]==t))}set(e,t){this.delete(e),this.append(e,t)}sort(){this._(this.v.sort(([e],[t])=>e<t?-1:+(e>t)))}toString(e){return r(e,this.v.map(e=>e.join(`=`)).join(`&`))}*entries(){for(let e of this.v)yield e}*keys(){for(let e of this.v)yield e[0]}*values(){for(let e of this.v)yield e[1]}[Symbol.iterator](){return this.entries()}};const n=/^[a-zA-Z][a-zA-Z\d+.-]*:/,r=(e,t)=>t&&e&&t[0]!=e?e+t:t;export{t as ReSearchParams,e as ReURL};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blyou/reurl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "A tiny zero-dependency URL parser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"url",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
23
24
|
"main": "./dist/index.cjs",
|
|
24
25
|
"module": "./dist/index.mjs",
|
|
25
26
|
"types": "./dist/index.d.cts",
|