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
35 lines
1.1 KiB
Plaintext
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()
|
|
})
|