This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

2
node_modules/fast-uri/.gitattributes generated vendored Normal file
View File

@@ -0,0 +1,2 @@
# Set default behavior to automatically convert line endings
* text=auto eol=lf

21
node_modules/fast-uri/.github/.stale.yml generated vendored Normal file
View File

@@ -0,0 +1,21 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 15
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- "discussion"
- "feature request"
- "bug"
- "help wanted"
- "plugin suggestion"
- "good first issue"
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

13
node_modules/fast-uri/.github/dependabot.yml generated vendored Normal file
View File

@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10

8
node_modules/fast-uri/.github/tests_checker.yml generated vendored Normal file
View File

@@ -0,0 +1,8 @@
comment: |
Hello! Thank you for contributing!
It appears that you have changed the code, but the tests that verify your change are missing. Could you please add them?
fileExtensions:
- '.ts'
- '.js'
testDir: 'test'

101
node_modules/fast-uri/.github/workflows/ci.yml generated vendored Normal file
View File

@@ -0,0 +1,101 @@
name: CI
on:
push:
branches:
- main
- next
- 'v*'
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
permissions:
contents: read
jobs:
test-regression-check-node10:
name: Test compatibility with Node.js 10
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '10'
cache: 'npm'
cache-dependency-path: package.json
check-latest: true
- name: Install
run: |
npm install --ignore-scripts
- name: Copy project as fast-uri to node_node_modules
run: |
rm -rf ./node_modules/fast-uri/lib &&
rm -rf ./node_modules/fast-uri/index.js &&
cp -r ./lib ./node_modules/fast-uri/lib &&
cp ./index.js ./node_modules/fast-uri/index.js
- name: Run tests
run: |
npm run test:unit
env:
NODE_OPTIONS: no-network-family-autoselection
test-browser:
name: Test browser compatibility
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
browser: ['chromium', 'firefox', 'webkit']
exclude:
- os: ubuntu-latest
browser: webkit
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: package.json
check-latest: true
- name: Install dependencies
run: |
npm install --ignore-scripts
- if: ${{ matrix.os == 'windows-latest' }}
run: npx playwright install winldd
- name: Run browser tests
run: |
npm run test:browser:${{ matrix.browser }}
test:
needs:
- test-regression-check-node10
permissions:
contents: write
pull-requests: write
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v5
with:
license-check: true
lint: true
node-versions: '["16", "18", "20", "22", "24"]'

View File

@@ -0,0 +1,24 @@
name: package-manager-ci
on:
push:
branches:
- main
- next
- 'v*'
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
permissions:
contents: read
jobs:
test:
permissions:
contents: read
uses: fastify/workflows/.github/workflows/plugins-ci-package-manager.yml@v5

32
node_modules/fast-uri/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,32 @@
Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
Copyright (c) 2021-present The Fastify team
All rights reserved.
The Fastify team members are listed at https://github.com/fastify/fastify#team.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The names of any contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* * *
The complete list of contributors can be found at:
- https://github.com/garycourt/uri-js/graphs/contributors

143
node_modules/fast-uri/README.md generated vendored Normal file
View File

@@ -0,0 +1,143 @@
# fast-uri
<div align="center">
[![NPM version](https://img.shields.io/npm/v/fast-uri.svg?style=flat)](https://www.npmjs.com/package/fast-uri)
[![CI](https://github.com/fastify/fast-uri/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fast-uri/actions/workflows/ci.yml)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
</div>
Dependency-free RFC 3986 URI toolbox.
## Usage
## Options
All of the above functions can accept an additional options argument that is an object that can contain one or more of the following properties:
* `scheme` (string)
Indicates the scheme that the URI should be treated as, overriding the URI's normal scheme parsing behavior.
* `reference` (string)
If set to `"suffix"`, it indicates that the URI is in the suffix format and the parser will use the option's `scheme` property to determine the URI's scheme.
* `tolerant` (boolean, false)
If set to `true`, the parser will relax URI resolving rules.
* `absolutePath` (boolean, false)
If set to `true`, the serializer will not resolve a relative `path` component.
* `unicodeSupport` (boolean, false)
If set to `true`, the parser will unescape non-ASCII characters in the parsed output as per [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt).
* `domainHost` (boolean, false)
If set to `true`, the library will treat the `host` component as a domain name, and convert IDNs (International Domain Names) as per [RFC 5891](http://www.ietf.org/rfc/rfc5891.txt).
### Parse
```js
const uri = require('fast-uri')
uri.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
// Output
{
scheme: "uri",
userinfo: "user:pass",
host: "example.com",
port: 123,
path: "/one/two.three",
query: "q1=a1&q2=a2",
fragment: "body"
}
```
### Serialize
```js
const uri = require('fast-uri')
uri.serialize({scheme: "http", host: "example.com", fragment: "footer"})
// Output
"http://example.com/#footer"
```
### Resolve
```js
const uri = require('fast-uri')
uri.resolve("uri://a/b/c/d?q", "../../g")
// Output
"uri://a/g"
```
### Equal
```js
const uri = require('fast-uri')
uri.equal("example://a/b/c/%7Bfoo%7D", "eXAMPLE://a/./b/../b/%63/%7bfoo%7d")
// Output
true
```
## Scheme supports
fast-uri supports inserting custom [scheme](http://en.wikipedia.org/wiki/URI_scheme)-dependent processing rules. Currently, fast-uri has built-in support for the following schemes:
* http \[[RFC 2616](http://www.ietf.org/rfc/rfc2616.txt)\]
* https \[[RFC 2818](http://www.ietf.org/rfc/rfc2818.txt)\]
* ws \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\]
* wss \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\]
* urn \[[RFC 2141](http://www.ietf.org/rfc/rfc2141.txt)\]
* urn:uuid \[[RFC 4122](http://www.ietf.org/rfc/rfc4122.txt)\]
## Benchmarks
```
fast-uri benchmark
┌─────────┬──────────────────────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼──────────────────────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0 │ 'fast-uri: parse domain' │ '951.31 ± 0.75%' │ '875.00 ± 11.00' │ '1122538 ± 0.01%' │ '1142857 ± 14550' │ 1051187 │
│ 1 │ 'fast-uri: parse IPv4' │ '443.44 ± 0.22%' │ '406.00 ± 3.00' │ '2422762 ± 0.01%' │ '2463054 ± 18335' │ 2255105 │
│ 2 │ 'fast-uri: parse IPv6' │ '1241.6 ± 1.74%' │ '1131.0 ± 30.00' │ '875177 ± 0.02%' │ '884173 ± 24092' │ 805399 │
│ 3 │ 'fast-uri: parse URN' │ '689.19 ± 4.29%' │ '618.00 ± 9.00' │ '1598373 ± 0.01%' │ '1618123 ± 23913' │ 1450972 │
│ 4 │ 'fast-uri: parse URN uuid' │ '1025.4 ± 2.02%' │ '921.00 ± 19.00' │ '1072419 ± 0.02%' │ '1085776 ± 22871' │ 975236 │
│ 5 │ 'fast-uri: serialize uri' │ '1028.5 ± 0.53%' │ '933.00 ± 43.00' │ '1063310 ± 0.02%' │ '1071811 ± 50523' │ 972249 │
│ 6 │ 'fast-uri: serialize long uri with dots' │ '1805.1 ± 0.52%' │ '1627.0 ± 17.00' │ '602620 ± 0.02%' │ '614628 ± 6490' │ 553997 │
│ 7 │ 'fast-uri: serialize IPv6' │ '2569.4 ± 2.69%' │ '2302.0 ± 21.00' │ '426080 ± 0.03%' │ '434405 ± 3999' │ 389194 │
│ 8 │ 'fast-uri: serialize ws' │ '979.39 ± 0.43%' │ '882.00 ± 8.00' │ '1111665 ± 0.02%' │ '1133787 ± 10378' │ 1021045 │
│ 9 │ 'fast-uri: resolve' │ '2208.2 ± 1.08%' │ '1980.0 ± 24.00' │ '495001 ± 0.03%' │ '505051 ± 6049' │ 452848 │
└─────────┴──────────────────────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
uri-js benchmark
┌─────────┬───────────────────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼───────────────────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0 │ 'urijs: parse domain' │ '3618.3 ± 0.43%' │ '3314.0 ± 33.00' │ '294875 ± 0.04%' │ '301750 ± 2975' │ 276375 │
│ 1 │ 'urijs: parse IPv4' │ '4024.1 ± 0.41%' │ '3751.0 ± 25.00' │ '261981 ± 0.04%' │ '266596 ± 1789' │ 248506 │
│ 2 │ 'urijs: parse IPv6' │ '5417.2 ± 0.46%' │ '4968.0 ± 43.00' │ '196023 ± 0.05%' │ '201288 ± 1727' │ 184598 │
│ 3 │ 'urijs: parse URN' │ '1324.2 ± 0.23%' │ '1229.0 ± 17.00' │ '801535 ± 0.02%' │ '813670 ± 11413' │ 755185 │
│ 4 │ 'urijs: parse URN uuid' │ '1822.0 ± 3.08%' │ '1655.0 ± 15.00' │ '594433 ± 0.02%' │ '604230 ± 5427' │ 548843 │
│ 5 │ 'urijs: serialize uri' │ '4196.8 ± 0.36%' │ '3908.0 ± 27.00' │ '251146 ± 0.04%' │ '255885 ± 1756' │ 238276 │
│ 6 │ 'urijs: serialize long uri with dots' │ '8331.0 ± 1.30%' │ '7658.0 ± 72.00' │ '126440 ± 0.07%' │ '130582 ± 1239' │ 120034 │
│ 7 │ 'urijs: serialize IPv6' │ '5685.5 ± 0.30%' │ '5366.0 ± 33.00' │ '182632 ± 0.05%' │ '186359 ± 1153' │ 175886 │
│ 8 │ 'urijs: serialize ws' │ '4159.3 ± 0.20%' │ '3899.0 ± 28.00' │ '250459 ± 0.04%' │ '256476 ± 1855' │ 240423 │
│ 9 │ 'urijs: resolve' │ '6729.9 ± 0.39%' │ '6261.0 ± 37.00' │ '156361 ± 0.06%' │ '159719 ± 949' │ 148591 │
└─────────┴───────────────────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
WHATWG URL benchmark
┌─────────┬────────────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0 │ 'WHATWG URL: parse domain' │ '475.22 ± 0.20%' │ '444.00 ± 5.00' │ '2217599 ± 0.01%' │ '2252252 ± 25652' │ 2104289 │
│ 1 │ 'WHATWG URL: parse URN' │ '384.78 ± 0.85%' │ '350.00 ± 5.00' │ '2809071 ± 0.01%' │ '2857143 ± 41408' │ 2598885 │
└─────────┴────────────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
```
## TODO
- [ ] Support MailTo
- [ ] Be 100% iso compatible with uri-js
## License
Licensed under [BSD-3-Clause](./LICENSE).

159
node_modules/fast-uri/benchmark/benchmark.mjs generated vendored Normal file
View File

@@ -0,0 +1,159 @@
import { Bench } from 'tinybench'
import { fastUri } from '../index.js'
import { parse as uriJsParse, serialize as uriJsSerialize, resolve as uriJsResolve, equal as uriJsEqual } from 'uri-js'
const base = 'uri://a/b/c/d;p?q'
const domain = 'https://example.com/foo#bar$fiz'
const ipv4 = '//10.10.10.10'
const ipv6 = '//[2001:db8::7]'
const urn = 'urn:foo:a123,456'
const urnuuid = 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
const urnuuidComponent = {
scheme: 'urn',
nid: 'uuid',
uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
}
const {
parse: fastUriParse,
serialize: fastUriSerialize,
resolve: fastUriResolve,
equal: fastUriEqual,
} = fastUri
// Initialization as there is a lot to parse at first
// eg: regexes
fastUriParse(domain)
uriJsParse(domain)
const benchFastUri = new Bench({ name: 'fast-uri benchmark' })
const benchUriJs = new Bench({ name: 'uri-js benchmark' })
const benchWHATWG = new Bench({ name: 'WHATWG URL benchmark' })
benchFastUri.add('fast-uri: parse domain', function () {
fastUriParse(domain)
})
benchUriJs.add('urijs: parse domain', function () {
uriJsParse(domain)
})
benchWHATWG.add('WHATWG URL: parse domain', function () {
// eslint-disable-next-line
new URL(domain)
})
benchFastUri.add('fast-uri: parse IPv4', function () {
fastUriParse(ipv4)
})
benchUriJs.add('urijs: parse IPv4', function () {
uriJsParse(ipv4)
})
benchFastUri.add('fast-uri: parse IPv6', function () {
fastUriParse(ipv6)
})
benchUriJs.add('urijs: parse IPv6', function () {
uriJsParse(ipv6)
})
benchFastUri.add('fast-uri: parse URN', function () {
fastUriParse(urn)
})
benchUriJs.add('urijs: parse URN', function () {
uriJsParse(urn)
})
benchWHATWG.add('WHATWG URL: parse URN', function () {
// eslint-disable-next-line
new URL(urn)
})
benchFastUri.add('fast-uri: parse URN uuid', function () {
fastUriParse(urnuuid)
})
benchUriJs.add('urijs: parse URN uuid', function () {
uriJsParse(urnuuid)
})
benchFastUri.add('fast-uri: serialize URN uuid', function () {
fastUriSerialize(urnuuidComponent)
})
benchUriJs.add('uri-js: serialize URN uuid', function () {
uriJsSerialize(urnuuidComponent)
})
benchFastUri.add('fast-uri: serialize uri', function () {
fastUriSerialize({
scheme: 'uri',
userinfo: 'foo:bar',
host: 'example.com',
port: 1,
path: 'path',
query: 'query',
fragment: 'fragment'
})
})
benchUriJs.add('urijs: serialize uri', function () {
uriJsSerialize({
scheme: 'uri',
userinfo: 'foo:bar',
host: 'example.com',
port: 1,
path: 'path',
query: 'query',
fragment: 'fragment'
})
})
benchFastUri.add('fast-uri: serialize long uri with dots', function () {
fastUriSerialize({
scheme: 'uri',
userinfo: 'foo:bar',
host: 'example.com',
port: 1,
path: './a/./b/c/../.././d/../e/f/.././/',
query: 'query',
fragment: 'fragment'
})
})
benchUriJs.add('urijs: serialize long uri with dots', function () {
uriJsSerialize({
scheme: 'uri',
userinfo: 'foo:bar',
host: 'example.com',
port: 1,
path: './a/./b/c/../.././d/../e/f/.././/',
query: 'query',
fragment: 'fragment'
})
})
benchFastUri.add('fast-uri: serialize IPv6', function () {
fastUriSerialize({ host: '2606:2800:220:1:248:1893:25c8:1946' })
})
benchUriJs.add('urijs: serialize IPv6', function () {
uriJsSerialize({ host: '2606:2800:220:1:248:1893:25c8:1946' })
})
benchFastUri.add('fast-uri: serialize ws', function () {
fastUriSerialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: true })
})
benchUriJs.add('urijs: serialize ws', function () {
uriJsSerialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: true })
})
benchFastUri.add('fast-uri: resolve', function () {
fastUriResolve(base, '../../../g')
})
benchUriJs.add('urijs: resolve', function () {
uriJsResolve(base, '../../../g')
})
benchFastUri.add('fast-uri: equal', function () {
fastUriEqual('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d')
})
benchUriJs.add('urijs: equal', function () {
uriJsEqual('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d')
})
await benchFastUri.run()
console.log(benchFastUri.name)
console.table(benchFastUri.table())
await benchUriJs.run()
console.log(benchUriJs.name)
console.table(benchUriJs.table())
await benchWHATWG.run()
console.log(benchWHATWG.name)
console.table(benchWHATWG.table())

51
node_modules/fast-uri/benchmark/equal.mjs generated vendored Normal file
View File

@@ -0,0 +1,51 @@
import { Bench } from 'tinybench'
import { fastUri } from '../index.js'
const {
equal: fastUriEqual,
parse: fastUriParse,
} = fastUri
const stringA = 'example://a/b/c/%7Bfoo%7D'
const stringB = 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'
const componentA = fastUriParse(stringA)
const componentB = fastUriParse(stringB)
const benchFastUri = new Bench({ name: 'fast-uri equal' })
benchFastUri.add('equal string with string', function () {
fastUriEqual(stringA, stringA)
})
benchFastUri.add('equal component with component', function () {
fastUriEqual(componentA, componentA)
})
benchFastUri.add('equal component with string', function () {
fastUriEqual(componentA, stringA)
})
benchFastUri.add('equal string with component', function () {
fastUriEqual(stringA, componentA)
})
benchFastUri.add('not equal string with string', function () {
fastUriEqual(stringA, stringB)
})
benchFastUri.add('not equal component with component', function () {
fastUriEqual(componentA, componentB)
})
benchFastUri.add('not equal component with string', function () {
fastUriEqual(componentA, stringB)
})
benchFastUri.add('not equal string with component', function () {
fastUriEqual(stringA, componentB)
})
await benchFastUri.run()
console.log(benchFastUri.name)
console.table(benchFastUri.table())

22
node_modules/fast-uri/benchmark/non-simple-domain.mjs generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import { Bench } from 'tinybench'
import { nonSimpleDomain } from '../lib/utils.js'
const benchNonSimpleDomain = new Bench({ name: 'nonSimpleDomain' })
const exampleCom = 'example.com'
const exaumlmpleCom = 'exämple.com'
const longDomain = 'abc'.repeat(100) + '.com'
console.assert(nonSimpleDomain(exampleCom) === false, 'example.com should be a simple domain')
console.assert(nonSimpleDomain(exaumlmpleCom) === true, 'exämple.com should not be a simple domain')
console.assert(nonSimpleDomain(longDomain) === false, `${longDomain} should be a simple domain?`)
benchNonSimpleDomain.add('nonSimpleDomain', function () {
nonSimpleDomain(exampleCom)
nonSimpleDomain(exaumlmpleCom)
nonSimpleDomain(longDomain)
})
await benchNonSimpleDomain.run()
console.log(benchNonSimpleDomain.name)
console.table(benchNonSimpleDomain.table())

17
node_modules/fast-uri/benchmark/package.json generated vendored Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "benchmark",
"version": "1.0.0",
"description": "",
"main": "index.js",
"private": true,
"scripts": {
"bench": "node benchmark.mjs"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"tinybench": "^5.0.0",
"uri-js": "^4.4.1"
}
}

View File

@@ -0,0 +1,24 @@
import { Bench } from 'tinybench'
import { stringArrayToHexStripped } from '../lib/utils.js'
const benchStringArrayToHexStripped = new Bench({ name: 'stringArrayToHexStripped' })
const case1 = ['0', '0', '0', '0']
const case2 = ['0', '0', '0', '1']
const case3 = ['0', '0', '1', '0']
const case4 = ['0', '1', '0', '0']
const case5 = ['1', '0', '0', '0']
const case6 = ['1', '0', '0', '1']
benchStringArrayToHexStripped.add('stringArrayToHexStripped', function () {
stringArrayToHexStripped(case1)
stringArrayToHexStripped(case2)
stringArrayToHexStripped(case3)
stringArrayToHexStripped(case4)
stringArrayToHexStripped(case5)
stringArrayToHexStripped(case6)
})
await benchStringArrayToHexStripped.run()
console.log(benchStringArrayToHexStripped.name)
console.table(benchStringArrayToHexStripped.table())

65
node_modules/fast-uri/benchmark/ws-is-secure.mjs generated vendored Normal file
View File

@@ -0,0 +1,65 @@
import { Bench } from 'tinybench'
import { wsIsSecure } from '../lib/schemes.js'
const benchWsIsSecure = new Bench({ name: 'wsIsSecure' })
const wsComponentAttributeSecureTrue = {
scheme: 'ws',
secure: true,
}
const wsComponentAttributeSecureFalse = {
scheme: 'ws',
secure: false,
}
const wssComponent = {
scheme: 'wss',
}
const wssComponentMixedCase = {
scheme: 'Wss',
}
const wssComponentUpperCase = {
scheme: 'WSS',
}
const httpComponent = {
scheme: 'http',
}
console.assert(wsIsSecure(wsComponentAttributeSecureTrue) === true, 'wsComponentAttributeSecureTrue should be secure')
console.assert(wsIsSecure(wsComponentAttributeSecureFalse) === false, 'wsComponentAttributeSecureFalse should not be secure')
console.assert(wsIsSecure(wssComponent) === true, 'wssComponent should be secure')
console.assert(wsIsSecure(wssComponentMixedCase) === true, 'wssComponentMixedCase should be secure')
console.assert(wsIsSecure(wssComponentUpperCase) === true, 'wssComponentUpperCase should be secure')
console.assert(wsIsSecure(httpComponent) === false, 'httpComponent should not be secure')
benchWsIsSecure.add(JSON.stringify(wsComponentAttributeSecureFalse), function () {
wsIsSecure(wsComponentAttributeSecureFalse)
})
benchWsIsSecure.add(JSON.stringify(wsComponentAttributeSecureTrue), function () {
wsIsSecure(wsComponentAttributeSecureTrue)
})
benchWsIsSecure.add(JSON.stringify(wssComponent), function () {
wsIsSecure(wssComponent)
})
benchWsIsSecure.add(JSON.stringify(wssComponentMixedCase), function () {
wsIsSecure(wssComponentMixedCase)
})
benchWsIsSecure.add(JSON.stringify(wssComponentUpperCase), function () {
wsIsSecure(wssComponentUpperCase)
})
benchWsIsSecure.add(JSON.stringify(httpComponent), function () {
wsIsSecure(httpComponent)
})
await benchWsIsSecure.run()
console.log(benchWsIsSecure.name)
console.table(benchWsIsSecure.table())

6
node_modules/fast-uri/eslint.config.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
'use strict'
module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
ts: true
})

340
node_modules/fast-uri/index.js generated vendored Normal file
View File

@@ -0,0 +1,340 @@
'use strict'
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require('./lib/utils')
const { SCHEMES, getSchemeHandler } = require('./lib/schemes')
/**
* @template {import('./types/index').URIComponent|string} T
* @param {T} uri
* @param {import('./types/index').Options} [options]
* @returns {T}
*/
function normalize (uri, options) {
if (typeof uri === 'string') {
uri = /** @type {T} */ (serialize(parse(uri, options), options))
} else if (typeof uri === 'object') {
uri = /** @type {T} */ (parse(serialize(uri, options), options))
}
return uri
}
/**
* @param {string} baseURI
* @param {string} relativeURI
* @param {import('./types/index').Options} [options]
* @returns {string}
*/
function resolve (baseURI, relativeURI, options) {
const schemelessOptions = options ? Object.assign({ scheme: 'null' }, options) : { scheme: 'null' }
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true)
schemelessOptions.skipEscape = true
return serialize(resolved, schemelessOptions)
}
/**
* @param {import ('./types/index').URIComponent} base
* @param {import ('./types/index').URIComponent} relative
* @param {import('./types/index').Options} [options]
* @param {boolean} [skipNormalization=false]
* @returns {import ('./types/index').URIComponent}
*/
function resolveComponent (base, relative, options, skipNormalization) {
/** @type {import('./types/index').URIComponent} */
const target = {}
if (!skipNormalization) {
base = parse(serialize(base, options), options) // normalize base component
relative = parse(serialize(relative, options), options) // normalize relative component
}
options = options || {}
if (!options.tolerant && relative.scheme) {
target.scheme = relative.scheme
// target.authority = relative.authority;
target.userinfo = relative.userinfo
target.host = relative.host
target.port = relative.port
target.path = removeDotSegments(relative.path || '')
target.query = relative.query
} else {
if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
// target.authority = relative.authority;
target.userinfo = relative.userinfo
target.host = relative.host
target.port = relative.port
target.path = removeDotSegments(relative.path || '')
target.query = relative.query
} else {
if (!relative.path) {
target.path = base.path
if (relative.query !== undefined) {
target.query = relative.query
} else {
target.query = base.query
}
} else {
if (relative.path[0] === '/') {
target.path = removeDotSegments(relative.path)
} else {
if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
target.path = '/' + relative.path
} else if (!base.path) {
target.path = relative.path
} else {
target.path = base.path.slice(0, base.path.lastIndexOf('/') + 1) + relative.path
}
target.path = removeDotSegments(target.path)
}
target.query = relative.query
}
// target.authority = base.authority;
target.userinfo = base.userinfo
target.host = base.host
target.port = base.port
}
target.scheme = base.scheme
}
target.fragment = relative.fragment
return target
}
/**
* @param {import ('./types/index').URIComponent|string} uriA
* @param {import ('./types/index').URIComponent|string} uriB
* @param {import ('./types/index').Options} options
* @returns {boolean}
*/
function equal (uriA, uriB, options) {
if (typeof uriA === 'string') {
uriA = unescape(uriA)
uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), { ...options, skipEscape: true })
} else if (typeof uriA === 'object') {
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true })
}
if (typeof uriB === 'string') {
uriB = unescape(uriB)
uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), { ...options, skipEscape: true })
} else if (typeof uriB === 'object') {
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true })
}
return uriA.toLowerCase() === uriB.toLowerCase()
}
/**
* @param {Readonly<import('./types/index').URIComponent>} cmpts
* @param {import('./types/index').Options} [opts]
* @returns {string}
*/
function serialize (cmpts, opts) {
const component = {
host: cmpts.host,
scheme: cmpts.scheme,
userinfo: cmpts.userinfo,
port: cmpts.port,
path: cmpts.path,
query: cmpts.query,
nid: cmpts.nid,
nss: cmpts.nss,
uuid: cmpts.uuid,
fragment: cmpts.fragment,
reference: cmpts.reference,
resourceName: cmpts.resourceName,
secure: cmpts.secure,
error: ''
}
const options = Object.assign({}, opts)
const uriTokens = []
// find scheme handler
const schemeHandler = getSchemeHandler(options.scheme || component.scheme)
// perform scheme specific serialization
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options)
if (component.path !== undefined) {
if (!options.skipEscape) {
component.path = escape(component.path)
if (component.scheme !== undefined) {
component.path = component.path.split('%3A').join(':')
}
} else {
component.path = unescape(component.path)
}
}
if (options.reference !== 'suffix' && component.scheme) {
uriTokens.push(component.scheme, ':')
}
const authority = recomposeAuthority(component)
if (authority !== undefined) {
if (options.reference !== 'suffix') {
uriTokens.push('//')
}
uriTokens.push(authority)
if (component.path && component.path[0] !== '/') {
uriTokens.push('/')
}
}
if (component.path !== undefined) {
let s = component.path
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
s = removeDotSegments(s)
}
if (
authority === undefined &&
s[0] === '/' &&
s[1] === '/'
) {
// don't allow the path to start with "//"
s = '/%2F' + s.slice(2)
}
uriTokens.push(s)
}
if (component.query !== undefined) {
uriTokens.push('?', component.query)
}
if (component.fragment !== undefined) {
uriTokens.push('#', component.fragment)
}
return uriTokens.join('')
}
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u
/**
* @param {string} uri
* @param {import('./types/index').Options} [opts]
* @returns
*/
function parse (uri, opts) {
const options = Object.assign({}, opts)
/** @type {import('./types/index').URIComponent} */
const parsed = {
scheme: undefined,
userinfo: undefined,
host: '',
port: undefined,
path: '',
query: undefined,
fragment: undefined
}
let isIP = false
if (options.reference === 'suffix') {
if (options.scheme) {
uri = options.scheme + ':' + uri
} else {
uri = '//' + uri
}
}
const matches = uri.match(URI_PARSE)
if (matches) {
// store each component
parsed.scheme = matches[1]
parsed.userinfo = matches[3]
parsed.host = matches[4]
parsed.port = parseInt(matches[5], 10)
parsed.path = matches[6] || ''
parsed.query = matches[7]
parsed.fragment = matches[8]
// fix port number
if (isNaN(parsed.port)) {
parsed.port = matches[5]
}
if (parsed.host) {
const ipv4result = isIPv4(parsed.host)
if (ipv4result === false) {
const ipv6result = normalizeIPv6(parsed.host)
parsed.host = ipv6result.host.toLowerCase()
isIP = ipv6result.isIPV6
} else {
isIP = true
}
}
if (parsed.scheme === undefined && parsed.userinfo === undefined && parsed.host === undefined && parsed.port === undefined && parsed.query === undefined && !parsed.path) {
parsed.reference = 'same-document'
} else if (parsed.scheme === undefined) {
parsed.reference = 'relative'
} else if (parsed.fragment === undefined) {
parsed.reference = 'absolute'
} else {
parsed.reference = 'uri'
}
// check for reference errors
if (options.reference && options.reference !== 'suffix' && options.reference !== parsed.reference) {
parsed.error = parsed.error || 'URI is not a ' + options.reference + ' reference.'
}
// find scheme handler
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme)
// check if scheme can't handle IRIs
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
// if host component is a domain name
if (parsed.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost)) && isIP === false && nonSimpleDomain(parsed.host)) {
// convert Unicode IDN -> ASCII IDN
try {
parsed.host = URL.domainToASCII(parsed.host.toLowerCase())
} catch (e) {
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e
}
}
// convert IRI -> URI
}
if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {
if (uri.indexOf('%') !== -1) {
if (parsed.scheme !== undefined) {
parsed.scheme = unescape(parsed.scheme)
}
if (parsed.host !== undefined) {
parsed.host = unescape(parsed.host)
}
}
if (parsed.path) {
parsed.path = escape(unescape(parsed.path))
}
if (parsed.fragment) {
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment))
}
}
// perform scheme specific parsing
if (schemeHandler && schemeHandler.parse) {
schemeHandler.parse(parsed, options)
}
} else {
parsed.error = parsed.error || 'URI can not be parsed.'
}
return parsed
}
const fastUri = {
SCHEMES,
normalize,
resolve,
resolveComponent,
equal,
serialize,
parse
}
module.exports = fastUri
module.exports.default = fastUri
module.exports.fastUri = fastUri

267
node_modules/fast-uri/lib/schemes.js generated vendored Normal file
View File

@@ -0,0 +1,267 @@
'use strict'
const { isUUID } = require('./utils')
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu
const supportedSchemeNames = /** @type {const} */ (['http', 'https', 'ws',
'wss', 'urn', 'urn:uuid'])
/** @typedef {supportedSchemeNames[number]} SchemeName */
/**
* @param {string} name
* @returns {name is SchemeName}
*/
function isValidSchemeName (name) {
return supportedSchemeNames.indexOf(/** @type {*} */ (name)) !== -1
}
/**
* @callback SchemeFn
* @param {import('../types/index').URIComponent} component
* @param {import('../types/index').Options} options
* @returns {import('../types/index').URIComponent}
*/
/**
* @typedef {Object} SchemeHandler
* @property {SchemeName} scheme - The scheme name.
* @property {boolean} [domainHost] - Indicates if the scheme supports domain hosts.
* @property {SchemeFn} parse - Function to parse the URI component for this scheme.
* @property {SchemeFn} serialize - Function to serialize the URI component for this scheme.
* @property {boolean} [skipNormalize] - Indicates if normalization should be skipped for this scheme.
* @property {boolean} [absolutePath] - Indicates if the scheme uses absolute paths.
* @property {boolean} [unicodeSupport] - Indicates if the scheme supports Unicode.
*/
/**
* @param {import('../types/index').URIComponent} wsComponent
* @returns {boolean}
*/
function wsIsSecure (wsComponent) {
if (wsComponent.secure === true) {
return true
} else if (wsComponent.secure === false) {
return false
} else if (wsComponent.scheme) {
return (
wsComponent.scheme.length === 3 &&
(wsComponent.scheme[0] === 'w' || wsComponent.scheme[0] === 'W') &&
(wsComponent.scheme[1] === 's' || wsComponent.scheme[1] === 'S') &&
(wsComponent.scheme[2] === 's' || wsComponent.scheme[2] === 'S')
)
} else {
return false
}
}
/** @type {SchemeFn} */
function httpParse (component) {
if (!component.host) {
component.error = component.error || 'HTTP URIs must have a host.'
}
return component
}
/** @type {SchemeFn} */
function httpSerialize (component) {
const secure = String(component.scheme).toLowerCase() === 'https'
// normalize the default port
if (component.port === (secure ? 443 : 80) || component.port === '') {
component.port = undefined
}
// normalize the empty path
if (!component.path) {
component.path = '/'
}
// NOTE: We do not parse query strings for HTTP URIs
// as WWW Form Url Encoded query strings are part of the HTML4+ spec,
// and not the HTTP spec.
return component
}
/** @type {SchemeFn} */
function wsParse (wsComponent) {
// indicate if the secure flag is set
wsComponent.secure = wsIsSecure(wsComponent)
// construct resouce name
wsComponent.resourceName = (wsComponent.path || '/') + (wsComponent.query ? '?' + wsComponent.query : '')
wsComponent.path = undefined
wsComponent.query = undefined
return wsComponent
}
/** @type {SchemeFn} */
function wsSerialize (wsComponent) {
// normalize the default port
if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === '') {
wsComponent.port = undefined
}
// ensure scheme matches secure flag
if (typeof wsComponent.secure === 'boolean') {
wsComponent.scheme = (wsComponent.secure ? 'wss' : 'ws')
wsComponent.secure = undefined
}
// reconstruct path from resource name
if (wsComponent.resourceName) {
const [path, query] = wsComponent.resourceName.split('?')
wsComponent.path = (path && path !== '/' ? path : undefined)
wsComponent.query = query
wsComponent.resourceName = undefined
}
// forbid fragment component
wsComponent.fragment = undefined
return wsComponent
}
/** @type {SchemeFn} */
function urnParse (urnComponent, options) {
if (!urnComponent.path) {
urnComponent.error = 'URN can not be parsed'
return urnComponent
}
const matches = urnComponent.path.match(URN_REG)
if (matches) {
const scheme = options.scheme || urnComponent.scheme || 'urn'
urnComponent.nid = matches[1].toLowerCase()
urnComponent.nss = matches[2]
const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`
const schemeHandler = getSchemeHandler(urnScheme)
urnComponent.path = undefined
if (schemeHandler) {
urnComponent = schemeHandler.parse(urnComponent, options)
}
} else {
urnComponent.error = urnComponent.error || 'URN can not be parsed.'
}
return urnComponent
}
/** @type {SchemeFn} */
function urnSerialize (urnComponent, options) {
if (urnComponent.nid === undefined) {
throw new Error('URN without nid cannot be serialized')
}
const scheme = options.scheme || urnComponent.scheme || 'urn'
const nid = urnComponent.nid.toLowerCase()
const urnScheme = `${scheme}:${options.nid || nid}`
const schemeHandler = getSchemeHandler(urnScheme)
if (schemeHandler) {
urnComponent = schemeHandler.serialize(urnComponent, options)
}
const uriComponent = urnComponent
const nss = urnComponent.nss
uriComponent.path = `${nid || options.nid}:${nss}`
options.skipEscape = true
return uriComponent
}
/** @type {SchemeFn} */
function urnuuidParse (urnComponent, options) {
const uuidComponent = urnComponent
uuidComponent.uuid = uuidComponent.nss
uuidComponent.nss = undefined
if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
uuidComponent.error = uuidComponent.error || 'UUID is not valid.'
}
return uuidComponent
}
/** @type {SchemeFn} */
function urnuuidSerialize (uuidComponent) {
const urnComponent = uuidComponent
// normalize UUID
urnComponent.nss = (uuidComponent.uuid || '').toLowerCase()
return urnComponent
}
const http = /** @type {SchemeHandler} */ ({
scheme: 'http',
domainHost: true,
parse: httpParse,
serialize: httpSerialize
})
const https = /** @type {SchemeHandler} */ ({
scheme: 'https',
domainHost: http.domainHost,
parse: httpParse,
serialize: httpSerialize
})
const ws = /** @type {SchemeHandler} */ ({
scheme: 'ws',
domainHost: true,
parse: wsParse,
serialize: wsSerialize
})
const wss = /** @type {SchemeHandler} */ ({
scheme: 'wss',
domainHost: ws.domainHost,
parse: ws.parse,
serialize: ws.serialize
})
const urn = /** @type {SchemeHandler} */ ({
scheme: 'urn',
parse: urnParse,
serialize: urnSerialize,
skipNormalize: true
})
const urnuuid = /** @type {SchemeHandler} */ ({
scheme: 'urn:uuid',
parse: urnuuidParse,
serialize: urnuuidSerialize,
skipNormalize: true
})
const SCHEMES = /** @type {Record<SchemeName, SchemeHandler>} */ ({
http,
https,
ws,
wss,
urn,
'urn:uuid': urnuuid
})
Object.setPrototypeOf(SCHEMES, null)
/**
* @param {string|undefined} scheme
* @returns {SchemeHandler|undefined}
*/
function getSchemeHandler (scheme) {
return (
scheme && (
SCHEMES[/** @type {SchemeName} */ (scheme)] ||
SCHEMES[/** @type {SchemeName} */(scheme.toLowerCase())])
) ||
undefined
}
module.exports = {
wsIsSecure,
SCHEMES,
isValidSchemeName,
getSchemeHandler,
}

336
node_modules/fast-uri/lib/utils.js generated vendored Normal file
View File

@@ -0,0 +1,336 @@
'use strict'
/** @type {(value: string) => boolean} */
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu)
/** @type {(value: string) => boolean} */
const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u)
/**
* @param {Array<string>} input
* @returns {string}
*/
function stringArrayToHexStripped (input) {
let acc = ''
let code = 0
let i = 0
for (i = 0; i < input.length; i++) {
code = input[i].charCodeAt(0)
if (code === 48) {
continue
}
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
return ''
}
acc += input[i]
break
}
for (i += 1; i < input.length; i++) {
code = input[i].charCodeAt(0)
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
return ''
}
acc += input[i]
}
return acc
}
/**
* @typedef {Object} GetIPV6Result
* @property {boolean} error - Indicates if there was an error parsing the IPv6 address.
* @property {string} address - The parsed IPv6 address.
* @property {string} [zone] - The zone identifier, if present.
*/
/**
* @param {string} value
* @returns {boolean}
*/
const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u)
/**
* @param {Array<string>} buffer
* @returns {boolean}
*/
function consumeIsZone (buffer) {
buffer.length = 0
return true
}
/**
* @param {Array<string>} buffer
* @param {Array<string>} address
* @param {GetIPV6Result} output
* @returns {boolean}
*/
function consumeHextets (buffer, address, output) {
if (buffer.length) {
const hex = stringArrayToHexStripped(buffer)
if (hex !== '') {
address.push(hex)
} else {
output.error = true
return false
}
buffer.length = 0
}
return true
}
/**
* @param {string} input
* @returns {GetIPV6Result}
*/
function getIPV6 (input) {
let tokenCount = 0
const output = { error: false, address: '', zone: '' }
/** @type {Array<string>} */
const address = []
/** @type {Array<string>} */
const buffer = []
let endipv6Encountered = false
let endIpv6 = false
let consume = consumeHextets
for (let i = 0; i < input.length; i++) {
const cursor = input[i]
if (cursor === '[' || cursor === ']') { continue }
if (cursor === ':') {
if (endipv6Encountered === true) {
endIpv6 = true
}
if (!consume(buffer, address, output)) { break }
if (++tokenCount > 7) {
// not valid
output.error = true
break
}
if (i > 0 && input[i - 1] === ':') {
endipv6Encountered = true
}
address.push(':')
continue
} else if (cursor === '%') {
if (!consume(buffer, address, output)) { break }
// switch to zone detection
consume = consumeIsZone
} else {
buffer.push(cursor)
continue
}
}
if (buffer.length) {
if (consume === consumeIsZone) {
output.zone = buffer.join('')
} else if (endIpv6) {
address.push(buffer.join(''))
} else {
address.push(stringArrayToHexStripped(buffer))
}
}
output.address = address.join('')
return output
}
/**
* @typedef {Object} NormalizeIPv6Result
* @property {string} host - The normalized host.
* @property {string} [escapedHost] - The escaped host.
* @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.
*/
/**
* @param {string} host
* @returns {NormalizeIPv6Result}
*/
function normalizeIPv6 (host) {
if (findToken(host, ':') < 2) { return { host, isIPV6: false } }
const ipv6 = getIPV6(host)
if (!ipv6.error) {
let newHost = ipv6.address
let escapedHost = ipv6.address
if (ipv6.zone) {
newHost += '%' + ipv6.zone
escapedHost += '%25' + ipv6.zone
}
return { host: newHost, isIPV6: true, escapedHost }
} else {
return { host, isIPV6: false }
}
}
/**
* @param {string} str
* @param {string} token
* @returns {number}
*/
function findToken (str, token) {
let ind = 0
for (let i = 0; i < str.length; i++) {
if (str[i] === token) ind++
}
return ind
}
/**
* @param {string} path
* @returns {string}
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
*/
function removeDotSegments (path) {
let input = path
const output = []
let nextSlash = -1
let len = 0
// eslint-disable-next-line no-cond-assign
while (len = input.length) {
if (len === 1) {
if (input === '.') {
break
} else if (input === '/') {
output.push('/')
break
} else {
output.push(input)
break
}
} else if (len === 2) {
if (input[0] === '.') {
if (input[1] === '.') {
break
} else if (input[1] === '/') {
input = input.slice(2)
continue
}
} else if (input[0] === '/') {
if (input[1] === '.' || input[1] === '/') {
output.push('/')
break
}
}
} else if (len === 3) {
if (input === '/..') {
if (output.length !== 0) {
output.pop()
}
output.push('/')
break
}
}
if (input[0] === '.') {
if (input[1] === '.') {
if (input[2] === '/') {
input = input.slice(3)
continue
}
} else if (input[1] === '/') {
input = input.slice(2)
continue
}
} else if (input[0] === '/') {
if (input[1] === '.') {
if (input[2] === '/') {
input = input.slice(2)
continue
} else if (input[2] === '.') {
if (input[3] === '/') {
input = input.slice(3)
if (output.length !== 0) {
output.pop()
}
continue
}
}
}
}
// Rule 2E: Move normal path segment to output
if ((nextSlash = input.indexOf('/', 1)) === -1) {
output.push(input)
break
} else {
output.push(input.slice(0, nextSlash))
input = input.slice(nextSlash)
}
}
return output.join('')
}
/**
* @param {import('../types/index').URIComponent} component
* @param {boolean} esc
* @returns {import('../types/index').URIComponent}
*/
function normalizeComponentEncoding (component, esc) {
const func = esc !== true ? escape : unescape
if (component.scheme !== undefined) {
component.scheme = func(component.scheme)
}
if (component.userinfo !== undefined) {
component.userinfo = func(component.userinfo)
}
if (component.host !== undefined) {
component.host = func(component.host)
}
if (component.path !== undefined) {
component.path = func(component.path)
}
if (component.query !== undefined) {
component.query = func(component.query)
}
if (component.fragment !== undefined) {
component.fragment = func(component.fragment)
}
return component
}
/**
* @param {import('../types/index').URIComponent} component
* @returns {string|undefined}
*/
function recomposeAuthority (component) {
const uriTokens = []
if (component.userinfo !== undefined) {
uriTokens.push(component.userinfo)
uriTokens.push('@')
}
if (component.host !== undefined) {
let host = unescape(component.host)
if (!isIPv4(host)) {
const ipV6res = normalizeIPv6(host)
if (ipV6res.isIPV6 === true) {
host = `[${ipV6res.escapedHost}]`
} else {
host = component.host
}
}
uriTokens.push(host)
}
if (typeof component.port === 'number' || typeof component.port === 'string') {
uriTokens.push(':')
uriTokens.push(String(component.port))
}
return uriTokens.length ? uriTokens.join('') : undefined
};
module.exports = {
nonSimpleDomain,
recomposeAuthority,
normalizeComponentEncoding,
removeDotSegments,
isIPv4,
isUUID,
normalizeIPv6,
stringArrayToHexStripped
}

69
node_modules/fast-uri/package.json generated vendored Normal file
View File

@@ -0,0 +1,69 @@
{
"name": "fast-uri",
"description": "Dependency-free RFC 3986 URI toolbox",
"version": "3.1.0",
"main": "index.js",
"type": "commonjs",
"types": "types/index.d.ts",
"license": "BSD-3-Clause",
"author": "Vincent Le Goff <vince.legoff@gmail.com> (https://github.com/zekth)",
"contributors": [
{
"name": "Matteo Collina",
"email": "hello@matteocollina.com"
},
{
"name": "Gürgün Dayıoğlu",
"email": "hey@gurgun.day",
"url": "https://heyhey.to/G"
},
{
"name": "Aras Abbasi",
"email": "aras.abbasi@gmail.com"
},
{
"name": "Frazer Smith",
"email": "frazer.dev@icloud.com",
"url": "https://github.com/fdawgs"
}
],
"repository": {
"type": "git",
"url": "git+https://github.com/fastify/fast-uri.git"
},
"bugs": {
"url": "https://github.com/fastify/fast-uri/issues"
},
"homepage": "https://github.com/fastify/fast-uri",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"scripts": {
"lint": "eslint",
"lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:browser:chromium": "playwright-test ./test/* --runner tape --browser=chromium",
"test:browser:firefox": "playwright-test ./test/* --runner tape --browser=firefox",
"test:browser:webkit": "playwright-test ./test/* --runner tape --browser=webkit",
"test:browser": "npm run test:browser:chromium && npm run test:browser:firefox && npm run test:browser:webkit",
"test:unit": "tape test/**/*.js",
"test:unit:dev": "npm run test:unit -- --coverage-report=html",
"test:typescript": "tsd"
},
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"ajv": "^8.16.0",
"eslint": "^9.17.0",
"neostandard": "^0.12.0",
"playwright-test": "^14.1.12",
"tape": "^5.8.1",
"tsd": "^0.32.0"
}
}

9
node_modules/fast-uri/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"strict": true,
"noImplicitAny": true,
"target": "es2015"
}
}

60
node_modules/fast-uri/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,60 @@
type FastUri = typeof fastUri
declare namespace fastUri {
export interface URIComponent {
scheme?: string;
userinfo?: string;
host?: string;
port?: number | string;
path?: string;
query?: string;
fragment?: string;
reference?: string;
nid?: string;
nss?: string;
resourceName?: string;
secure?: boolean;
uuid?: string;
error?: string;
}
export interface Options {
scheme?: string;
reference?: string;
unicodeSupport?: boolean;
domainHost?: boolean;
absolutePath?: boolean;
tolerant?: boolean;
skipEscape?: boolean;
nid?: string;
}
/**
* @deprecated Use Options instead
*/
export type options = Options
/**
* @deprecated Use URIComponent instead
*/
export type URIComponents = URIComponent
export function normalize (uri: string, opts?: Options): string
export function normalize (uri: URIComponent, opts?: Options): URIComponent
export function normalize (uri: any, opts?: Options): any
export function resolve (baseURI: string, relativeURI: string, options?: Options): string
export function resolveComponent (base: URIComponent, relative: URIComponent, options?: Options, skipNormalization?: boolean): URIComponent
export function parse (uri: string, opts?: Options): URIComponent
export function serialize (component: URIComponent, opts?: Options): string
export function equal (uriA: string, uriB: string): boolean
export function resolve (base: string, path: string): string
export const fastUri: FastUri
export { fastUri as default }
}
export = fastUri

17
node_modules/fast-uri/types/index.test-d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import uri, { URIComponents, URIComponent, Options, options } from '..'
import { expectDeprecated, expectType } from 'tsd'
const parsed = uri.parse('foo')
expectType<URIComponents>(parsed)
const parsed2 = uri.parse('foo', {
domainHost: true,
scheme: 'https',
unicodeSupport: false
})
expectType<URIComponents>(parsed2)
expectType<URIComponent>({} as URIComponents)
expectDeprecated({} as URIComponents)
expectType<Options>({} as options)
expectDeprecated({} as options)