fast-uri 2.1.0 → 2.3.0
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/.gitattributes +2 -0
- package/.github/workflows/ci.yml +7 -0
- package/.github/workflows/package-manager-ci.yml +13 -59
- package/README.md +2 -2
- package/benchmark.js +2 -0
- package/index.js +34 -34
- package/lib/schemes.js +2 -2
- package/lib/utils.js +7 -7
- package/package.json +4 -5
- package/test/equal.test.js +55 -22
- package/types/index.d.ts +53 -0
- package/types/index.test-d.ts +17 -0
- package/index.d.ts +0 -27
- package/index.test-d.ts +0 -11
- package/types/.gitkeep +0 -0
package/.gitattributes
ADDED
package/.github/workflows/ci.yml
CHANGED
|
@@ -2,6 +2,11 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- master
|
|
8
|
+
- next
|
|
9
|
+
- 'v*'
|
|
5
10
|
paths-ignore:
|
|
6
11
|
- 'docs/**'
|
|
7
12
|
- '*.md'
|
|
@@ -13,3 +18,5 @@ on:
|
|
|
13
18
|
jobs:
|
|
14
19
|
test:
|
|
15
20
|
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
|
|
21
|
+
with:
|
|
22
|
+
license-check: true
|
|
@@ -3,64 +3,18 @@ name: package-manager-ci
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
- main
|
|
7
|
+
- master
|
|
8
|
+
- next
|
|
9
|
+
- 'v*'
|
|
10
|
+
paths-ignore:
|
|
11
|
+
- 'docs/**'
|
|
12
|
+
- '*.md'
|
|
13
|
+
pull_request:
|
|
14
|
+
paths-ignore:
|
|
15
|
+
- 'docs/**'
|
|
16
|
+
- '*.md'
|
|
10
17
|
|
|
11
18
|
jobs:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
# Maintenance and active LTS
|
|
18
|
-
node-version: [14, 16]
|
|
19
|
-
os: [ubuntu-18.04]
|
|
20
|
-
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v3
|
|
23
|
-
with:
|
|
24
|
-
persist-credentials: false
|
|
25
|
-
|
|
26
|
-
- name: Use Node.js
|
|
27
|
-
uses: actions/setup-node@v3
|
|
28
|
-
with:
|
|
29
|
-
node-version: ${{ matrix.node-version }}
|
|
30
|
-
|
|
31
|
-
- name: Install with pnpm
|
|
32
|
-
run: |
|
|
33
|
-
curl -L https://unpkg.com/@pnpm/self-installer | node
|
|
34
|
-
pnpm install
|
|
35
|
-
|
|
36
|
-
- name: Run tests
|
|
37
|
-
run: |
|
|
38
|
-
pnpm run test
|
|
39
|
-
|
|
40
|
-
yarn:
|
|
41
|
-
runs-on: ${{ matrix.os }}
|
|
42
|
-
|
|
43
|
-
strategy:
|
|
44
|
-
matrix:
|
|
45
|
-
# Maintenance and active LTS
|
|
46
|
-
node-version: [14, 16]
|
|
47
|
-
os: [ubuntu-18.04]
|
|
48
|
-
|
|
49
|
-
steps:
|
|
50
|
-
- uses: actions/checkout@v3
|
|
51
|
-
with:
|
|
52
|
-
persist-credentials: false
|
|
53
|
-
|
|
54
|
-
- name: Use Node.js
|
|
55
|
-
uses: actions/setup-node@v3
|
|
56
|
-
with:
|
|
57
|
-
node-version: ${{ matrix.node-version }}
|
|
58
|
-
|
|
59
|
-
- name: Install with yarn
|
|
60
|
-
run: |
|
|
61
|
-
curl -o- -L https://yarnpkg.com/install.sh | bash
|
|
62
|
-
yarn install --ignore-engines
|
|
63
|
-
|
|
64
|
-
- name: Run tests
|
|
65
|
-
run: |
|
|
66
|
-
yarn run test
|
|
19
|
+
test:
|
|
20
|
+
uses: fastify/workflows/.github/workflows/plugins-ci-package-manager.yml@v3
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[](https://github.com/fastify/fast-uri/actions/workflows/ci.yml)
|
|
6
6
|
[](https://standardjs.com/)
|
|
7
7
|
|
|
8
8
|
</div>
|
|
@@ -122,4 +122,4 @@ urijs: resolve x 225,759 ops/sec ±0.37% (95 runs sampled)
|
|
|
122
122
|
|
|
123
123
|
- [ ] Support MailTo
|
|
124
124
|
- [ ] Be 100% iso compatible with uri-js
|
|
125
|
-
- [ ] Add browser test stack
|
|
125
|
+
- [ ] Add browser test stack
|
package/benchmark.js
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const URL = require('url')
|
|
3
|
+
const URL = require('node:url')
|
|
4
4
|
const { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = require('./lib/utils')
|
|
5
5
|
const SCHEMES = require('./lib/schemes')
|
|
6
6
|
|
|
@@ -160,7 +160,7 @@ function serialize (cmpts, opts) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
if (authority === undefined) {
|
|
163
|
-
s = s.replace(
|
|
163
|
+
s = s.replace(/^\/\//u, '/%2F') // don't allow the path to start with "//"
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
uriTokens.push(s)
|
|
@@ -178,8 +178,20 @@ function serialize (cmpts, opts) {
|
|
|
178
178
|
return uriTokens.join('')
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
const
|
|
182
|
-
|
|
181
|
+
const hexLookUp = Array.from({ length: 127 }, (v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)))
|
|
182
|
+
|
|
183
|
+
function nonSimpleDomain (value) {
|
|
184
|
+
let code = 0
|
|
185
|
+
for (let i = 0, len = value.length; i < len; ++i) {
|
|
186
|
+
code = value.charCodeAt(i)
|
|
187
|
+
if (code > 126 || hexLookUp[code]) {
|
|
188
|
+
return true
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return false
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u
|
|
183
195
|
|
|
184
196
|
function parse (uri, opts) {
|
|
185
197
|
const options = Object.assign({}, opts)
|
|
@@ -198,34 +210,18 @@ function parse (uri, opts) {
|
|
|
198
210
|
const matches = uri.match(URI_PARSE)
|
|
199
211
|
|
|
200
212
|
if (matches) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
parsed.port = matches[5]
|
|
214
|
-
}
|
|
215
|
-
} else { // IE FIX for improper RegExp matching
|
|
216
|
-
// store each component
|
|
217
|
-
parsed.scheme = matches[1] || undefined
|
|
218
|
-
parsed.userinfo = (uri.indexOf('@') !== -1 ? matches[3] : undefined)
|
|
219
|
-
parsed.host = (uri.indexOf('//') !== -1 ? matches[4] : undefined)
|
|
220
|
-
parsed.port = parseInt(matches[5], 10)
|
|
221
|
-
parsed.path = matches[6] || ''
|
|
222
|
-
parsed.query = (uri.indexOf('?') !== -1 ? matches[7] : undefined)
|
|
223
|
-
parsed.fragment = (uri.indexOf('#') !== -1 ? matches[8] : undefined)
|
|
224
|
-
|
|
225
|
-
// fix port number
|
|
226
|
-
if (isNaN(parsed.port)) {
|
|
227
|
-
parsed.port = (uri.match(/\/\/(?:.|\n)*:(?:\/|\?|#|$)/) ? matches[4] : undefined)
|
|
228
|
-
}
|
|
213
|
+
// store each component
|
|
214
|
+
parsed.scheme = matches[1]
|
|
215
|
+
parsed.userinfo = matches[3]
|
|
216
|
+
parsed.host = matches[4]
|
|
217
|
+
parsed.port = parseInt(matches[5], 10)
|
|
218
|
+
parsed.path = matches[6] || ''
|
|
219
|
+
parsed.query = matches[7]
|
|
220
|
+
parsed.fragment = matches[8]
|
|
221
|
+
|
|
222
|
+
// fix port number
|
|
223
|
+
if (isNaN(parsed.port)) {
|
|
224
|
+
parsed.port = matches[5]
|
|
229
225
|
}
|
|
230
226
|
if (parsed.host) {
|
|
231
227
|
const ipv4result = normalizeIPv4(parsed.host)
|
|
@@ -256,7 +252,7 @@ function parse (uri, opts) {
|
|
|
256
252
|
// check if scheme can't handle IRIs
|
|
257
253
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
258
254
|
// if host component is a domain name
|
|
259
|
-
if (parsed.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost))) {
|
|
255
|
+
if (parsed.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost)) && nonSimpleDomain(parsed.host)) {
|
|
260
256
|
// convert Unicode IDN -> ASCII IDN
|
|
261
257
|
try {
|
|
262
258
|
parsed.host = URL.domainToASCII(parsed.host.toLowerCase())
|
|
@@ -295,7 +291,7 @@ function parse (uri, opts) {
|
|
|
295
291
|
return parsed
|
|
296
292
|
}
|
|
297
293
|
|
|
298
|
-
|
|
294
|
+
const fastUri = {
|
|
299
295
|
normalize,
|
|
300
296
|
resolve,
|
|
301
297
|
resolveComponents,
|
|
@@ -303,3 +299,7 @@ module.exports = {
|
|
|
303
299
|
serialize,
|
|
304
300
|
parse
|
|
305
301
|
}
|
|
302
|
+
|
|
303
|
+
module.exports = fastUri
|
|
304
|
+
module.exports.default = fastUri
|
|
305
|
+
module.exports.fastUri = fastUri
|
package/lib/schemes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const UUID_REG = /^[
|
|
4
|
-
const URN_REG = /([
|
|
3
|
+
const UUID_REG = /^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu
|
|
4
|
+
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu
|
|
5
5
|
|
|
6
6
|
function isSecure (wsComponents) {
|
|
7
7
|
return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === 'wss'
|
package/lib/utils.js
CHANGED
|
@@ -4,10 +4,10 @@ const { HEX } = require('./scopedChars')
|
|
|
4
4
|
|
|
5
5
|
function normalizeIPv4 (host) {
|
|
6
6
|
if (findToken(host, '.') < 3) { return { host, isIPV4: false } }
|
|
7
|
-
const matches = host.match(/^(\
|
|
7
|
+
const matches = host.match(/^(\b[01]?\d{1,2}|\b2[0-4]\d|\b25[0-5])(\.([01]?\d{1,2}|2[0-4]\d|25[0-5])){3}$/u) || []
|
|
8
8
|
const [address] = matches
|
|
9
9
|
if (address) {
|
|
10
|
-
return { host: stripLeadingZeros(address, '.'
|
|
10
|
+
return { host: stripLeadingZeros(address, '.'), isIPV4: true }
|
|
11
11
|
} else {
|
|
12
12
|
return { host, isIPV4: false }
|
|
13
13
|
}
|
|
@@ -92,7 +92,7 @@ function getIPV6 (input) {
|
|
|
92
92
|
|
|
93
93
|
function normalizeIPv6 (host, opts = {}) {
|
|
94
94
|
if (findToken(host, ':') < 2) { return { host, isIPV6: false } }
|
|
95
|
-
const ipv6 = getIPV6(host
|
|
95
|
+
const ipv6 = getIPV6(host)
|
|
96
96
|
|
|
97
97
|
if (!ipv6.error) {
|
|
98
98
|
let newHost = ipv6.address
|
|
@@ -138,10 +138,10 @@ function findToken (str, token) {
|
|
|
138
138
|
return ind
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
const RDS1 = /^\.\.?\//
|
|
142
|
-
const RDS2 = /^\/\.(
|
|
143
|
-
const RDS3 = /^\/\.\.(
|
|
144
|
-
const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/
|
|
141
|
+
const RDS1 = /^\.\.?\//u
|
|
142
|
+
const RDS2 = /^\/\.(?:\/|$)/u
|
|
143
|
+
const RDS3 = /^\/\.\.(?:\/|$)/u
|
|
144
|
+
const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u
|
|
145
145
|
|
|
146
146
|
function removeDotSegments (input) {
|
|
147
147
|
const output = []
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-uri",
|
|
3
3
|
"description": "Dependency free RFC 3986 URI toolbox",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
7
|
-
"types": "index.d.ts",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"author": "Vincent Le Goff <vince.legoff@gmail.com> (https://github.com/zekth)",
|
|
10
10
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/fastify/fast-uri/issues"
|
|
16
16
|
},
|
|
17
|
-
"homepage":"https://github.com/fastify/fast-uri",
|
|
17
|
+
"homepage": "https://github.com/fastify/fast-uri",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"bench": "node benchmark.js",
|
|
20
20
|
"lint:fix": "standard --fix",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
"snazzy": "^9.0.0",
|
|
32
32
|
"standard": "^17.0.0",
|
|
33
33
|
"tap": "^16.0.0",
|
|
34
|
-
"tsd": "^0.
|
|
35
|
-
"typescript": "^4.4.4",
|
|
34
|
+
"tsd": "^0.29.0",
|
|
36
35
|
"uri-js": "^4.4.1"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {},
|
package/test/equal.test.js
CHANGED
|
@@ -4,12 +4,21 @@ const tap = require('tap')
|
|
|
4
4
|
const test = tap.test
|
|
5
5
|
const URI = require('../')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const fn = URI.equal
|
|
8
|
+
const runTest = (t, suite) => {
|
|
9
|
+
suite.forEach(s => {
|
|
10
|
+
const operator = s.result ? '==' : '!='
|
|
11
|
+
t.equal(fn(s.pair[0], s.pair[1]), s.result, `${s.pair[0]} ${operator} ${s.pair[1]}`)
|
|
12
|
+
t.equal(fn(s.pair[1], s.pair[0]), s.result, `${s.pair[1]} ${operator} ${s.pair[0]}`)
|
|
13
|
+
})
|
|
14
|
+
}
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
test('URI Equals', (t) => {
|
|
17
|
+
const suite = [
|
|
18
|
+
{ pair: ['example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'], result: true }, // test from RFC 3986
|
|
19
|
+
{ pair: ['http://example.org/~user', 'http://example.org/%7euser'], result: true } // test from RFC 3987
|
|
20
|
+
]
|
|
21
|
+
runTest(t, suite)
|
|
13
22
|
t.end()
|
|
14
23
|
})
|
|
15
24
|
|
|
@@ -20,39 +29,55 @@ test('URI Equals', (t) => {
|
|
|
20
29
|
// })
|
|
21
30
|
|
|
22
31
|
test('HTTP Equals', (t) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
const suite = [
|
|
33
|
+
// test from RFC 2616
|
|
34
|
+
{ pair: ['http://abc.com:80/~smith/home.html', 'http://abc.com/~smith/home.html'], result: true },
|
|
35
|
+
{ pair: [{ scheme: 'http', host: 'abc.com', port: 80, path: '/~smith/home.html' }, 'http://abc.com/~smith/home.html'], result: true },
|
|
36
|
+
{ pair: ['http://ABC.com/%7Esmith/home.html', 'http://abc.com/~smith/home.html'], result: true },
|
|
37
|
+
{ pair: ['http://ABC.com:/%7esmith/home.html', 'http://abc.com/~smith/home.html'], result: true },
|
|
38
|
+
{ pair: ['HTTP://ABC.COM', 'http://abc.com/'], result: true },
|
|
39
|
+
// test from RFC 3986
|
|
40
|
+
{ pair: ['http://example.com:/', 'http://example.com:80/'], result: true }
|
|
41
|
+
]
|
|
42
|
+
runTest(t, suite)
|
|
31
43
|
t.end()
|
|
32
44
|
})
|
|
33
45
|
|
|
34
46
|
test('HTTPS Equals', (t) => {
|
|
35
|
-
|
|
36
|
-
|
|
47
|
+
const suite = [
|
|
48
|
+
{ pair: ['https://example.com', 'https://example.com:443/'], result: true },
|
|
49
|
+
{ pair: ['https://example.com:/', 'https://example.com:443/'], result: true }
|
|
50
|
+
]
|
|
51
|
+
runTest(t, suite)
|
|
37
52
|
t.end()
|
|
38
53
|
})
|
|
39
54
|
|
|
40
55
|
test('URN Equals', (t) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
const suite = [
|
|
57
|
+
// test from RFC 2141
|
|
58
|
+
{ pair: ['urn:foo:a123,456', 'urn:foo:a123,456'], result: true },
|
|
59
|
+
{ pair: ['urn:foo:a123,456', 'URN:foo:a123,456'], result: true },
|
|
60
|
+
{ pair: ['urn:foo:a123,456', 'urn:FOO:a123,456'], result: true }
|
|
61
|
+
]
|
|
45
62
|
|
|
46
63
|
// Disabling for now as the whole equal logic might need
|
|
47
64
|
// to be refactored
|
|
48
65
|
// t.equal(URI.equal('urn:foo:a123,456', 'urn:foo:A123,456'), false)
|
|
49
66
|
// t.equal(URI.equal('urn:foo:a123%2C456', 'URN:FOO:a123%2c456'), true)
|
|
67
|
+
|
|
68
|
+
runTest(t, suite)
|
|
50
69
|
t.end()
|
|
51
70
|
})
|
|
71
|
+
|
|
52
72
|
test('UUID Equals', (t) => {
|
|
53
|
-
|
|
73
|
+
const suite = [
|
|
74
|
+
{ pair: ['URN:UUID:F81D4FAE-7DEC-11D0-A765-00A0C91E6BF6', 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6'], result: true }
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
runTest(t, suite)
|
|
54
78
|
t.end()
|
|
55
79
|
})
|
|
80
|
+
|
|
56
81
|
// test('Mailto Equals', (t) => {
|
|
57
82
|
// // tests from RFC 6068
|
|
58
83
|
// t.equal(URI.equal('mailto:addr1@an.example,addr2@an.example', 'mailto:?to=addr1@an.example,addr2@an.example'), true)
|
|
@@ -61,11 +86,19 @@ test('UUID Equals', (t) => {
|
|
|
61
86
|
// })
|
|
62
87
|
|
|
63
88
|
test('WS Equal', (t) => {
|
|
64
|
-
|
|
89
|
+
const suite = [
|
|
90
|
+
{ pair: ['WS://ABC.COM:80/chat#one', 'ws://abc.com/chat'], result: true }
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
runTest(t, suite)
|
|
65
94
|
t.end()
|
|
66
95
|
})
|
|
67
96
|
|
|
68
97
|
test('WSS Equal', (t) => {
|
|
69
|
-
|
|
98
|
+
const suite = [
|
|
99
|
+
{ pair: ['WSS://ABC.COM:443/chat#one', 'wss://abc.com/chat'], result: true }
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
runTest(t, suite)
|
|
70
103
|
t.end()
|
|
71
104
|
})
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
type FastUri = typeof fastUri
|
|
2
|
+
|
|
3
|
+
declare namespace fastUri {
|
|
4
|
+
export interface URIComponent {
|
|
5
|
+
scheme?: string;
|
|
6
|
+
userinfo?: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
port?: number | string;
|
|
9
|
+
path?: string;
|
|
10
|
+
query?: string;
|
|
11
|
+
fragment?: string;
|
|
12
|
+
reference?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Options {
|
|
16
|
+
scheme?: string;
|
|
17
|
+
reference?: string;
|
|
18
|
+
unicodeSupport?: boolean;
|
|
19
|
+
domainHost?: boolean;
|
|
20
|
+
absolutePath?: boolean;
|
|
21
|
+
tolerant?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use Options instead
|
|
26
|
+
*/
|
|
27
|
+
export type options = Options
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use URIComponent instead
|
|
30
|
+
*/
|
|
31
|
+
export type URIComponents = URIComponent
|
|
32
|
+
|
|
33
|
+
export function normalize(uri: string, opts?: Options): string;
|
|
34
|
+
export function normalize(uri: URIComponent, opts?: Options): URIComponent;
|
|
35
|
+
export function normalize(uri: any, opts?: Options): any;
|
|
36
|
+
|
|
37
|
+
export function resolve(baseURI: string, relativeURI: string, options?: Options): string
|
|
38
|
+
|
|
39
|
+
export function resolveComponent(base: URIComponent, relative: URIComponent, options?: Options, skipNormalization?: boolean): URIComponent
|
|
40
|
+
|
|
41
|
+
export function parse(uri: string, opts?: Options): URIComponent;
|
|
42
|
+
|
|
43
|
+
export function serialize(component: URIComponent, opts?: Options): string;
|
|
44
|
+
|
|
45
|
+
export function equal(uriA: string, uriB: string): boolean;
|
|
46
|
+
|
|
47
|
+
export function resolve(base: string, path: string): string;
|
|
48
|
+
|
|
49
|
+
export const fastUri: FastUri
|
|
50
|
+
export { fastUri as default }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export = fastUri
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import uri, { URIComponents, URIComponent, Options, options } from "..";
|
|
2
|
+
import { expectDeprecated, expectType } from "tsd";
|
|
3
|
+
|
|
4
|
+
const parsed = uri.parse("foo");
|
|
5
|
+
expectType<URIComponents>(parsed);
|
|
6
|
+
const parsed2 = uri.parse("foo", {
|
|
7
|
+
domainHost: true,
|
|
8
|
+
scheme: 'https',
|
|
9
|
+
unicodeSupport: false
|
|
10
|
+
})
|
|
11
|
+
expectType<URIComponents>(parsed2);
|
|
12
|
+
|
|
13
|
+
expectType<URIComponent>({} as URIComponents)
|
|
14
|
+
expectDeprecated({} as URIComponents)
|
|
15
|
+
|
|
16
|
+
expectType<Options>({} as options)
|
|
17
|
+
expectDeprecated({} as options)
|
package/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface URIComponents {
|
|
2
|
-
scheme?: string;
|
|
3
|
-
userinfo?: string;
|
|
4
|
-
host?: string;
|
|
5
|
-
port?: number | string;
|
|
6
|
-
path?: string;
|
|
7
|
-
query?: string;
|
|
8
|
-
fragment?: string;
|
|
9
|
-
reference?: string;
|
|
10
|
-
error?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface options {
|
|
13
|
-
scheme?: string;
|
|
14
|
-
reference?: string;
|
|
15
|
-
unicodeSupport?: boolean;
|
|
16
|
-
domainHost?: boolean;
|
|
17
|
-
absolutePath?: boolean;
|
|
18
|
-
tolerant?:boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function parse(uri: string, opts?: options): URIComponents;
|
|
22
|
-
|
|
23
|
-
export function serialize(component: URIComponents, opts?: options): string;
|
|
24
|
-
|
|
25
|
-
export function equal(uriA: string, uriB:string): boolean;
|
|
26
|
-
|
|
27
|
-
export function resolve(base:string, path:string): string;
|
package/index.test-d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import uri, { URIComponents } from ".";
|
|
2
|
-
import { expectType } from "tsd";
|
|
3
|
-
|
|
4
|
-
const parsed = uri.parse("foo");
|
|
5
|
-
expectType<URIComponents>(parsed);
|
|
6
|
-
const parsed2 = uri.parse("foo", {
|
|
7
|
-
domainHost: true,
|
|
8
|
-
scheme: 'https',
|
|
9
|
-
unicodeSupport: false
|
|
10
|
-
})
|
|
11
|
-
expectType<URIComponents>(parsed2);
|
package/types/.gitkeep
DELETED
|
File without changes
|