Files
SnowLuma/.pnpm-store/v11/files/e1/534f56107dac453d12d6f5f34c6264236066f2263f5336b9e05bbf4e391c054fa6264165e69e988c5030944f5608aaa630d0ab290e533744217bbf856cf1aa
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

35 lines
1.1 KiB
Plaintext

'use strict'
const test = require('tape')
const fastURI = require('..')
test('IPv6 hosts normalize to the RFC 5952 canonical form', (t) => {
const cases = [
['http://[0:0:0:0:0:0:0:1]/', 'http://[::1]/'],
['http://[0:0:0:0:0:0:0:0]/', 'http://[::]/'],
['http://[2001:0db8:0000:0000:0000:0000:0000:0001]/', 'http://[2001:db8::1]/'],
['http://[2001:0:0:0:0:0:0:1]/', 'http://[2001::1]/'],
['http://[fe80:0:0:0:0:0:0:1]/', 'http://[fe80::1]/'],
['http://[1:0:0:0:2:0:0:3]/', 'http://[1::2:0:0:3]/']
]
for (const [uri, normalized] of cases) {
t.equal(fastURI.normalize(uri), normalized, `${uri} normalizes to ${normalized}`)
}
t.end()
})
test('IPv6 equal() matches the same address across compressed and expanded forms', (t) => {
const pairs = [
['http://[::1]/', 'http://[0:0:0:0:0:0:0:1]/'],
['http://[::]/', 'http://[0:0:0:0:0:0:0:0]/'],
['http://[2001:db8::1]/', 'http://[2001:0db8:0000:0000:0000:0000:0000:0001]/'],
['http://[1::2:0:0:3]/', 'http://[1:0:0:0:2:0:0:3]/']
]
for (const [a, b] of pairs) {
t.equal(fastURI.equal(a, b), true, `${a} equals ${b}`)
}
t.end()
})