Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -1,14 +1,13 @@
'use strict'
const tap = require('tap')
const test = tap.test
const URI = require('../')
const test = require('tape')
const fastURI = require('..')
test('URI parse', (t) => {
let components
// scheme
components = URI.parse('uri:')
components = fastURI.parse('uri:')
t.equal(components.error, undefined, 'scheme errors')
t.equal(components.scheme, 'uri', 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -20,7 +19,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// userinfo
components = URI.parse('//@')
components = fastURI.parse('//@')
t.equal(components.error, undefined, 'userinfo errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, "@", "authority");
@@ -32,7 +31,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// host
components = URI.parse('//')
components = fastURI.parse('//')
t.equal(components.error, undefined, 'host errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, "", "authority");
@@ -44,7 +43,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// port
components = URI.parse('//:')
components = fastURI.parse('//:')
t.equal(components.error, undefined, 'port errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, ":", "authority");
@@ -56,7 +55,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// path
components = URI.parse('')
components = fastURI.parse('')
t.equal(components.error, undefined, 'path errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -68,7 +67,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// query
components = URI.parse('?')
components = fastURI.parse('?')
t.equal(components.error, undefined, 'query errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -80,7 +79,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// fragment
components = URI.parse('#')
components = fastURI.parse('#')
t.equal(components.error, undefined, 'fragment errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -92,7 +91,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, '', 'fragment')
// fragment with character tabulation
components = URI.parse('#\t')
components = fastURI.parse('#\t')
t.equal(components.error, undefined, 'path errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -104,7 +103,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, '%09', 'fragment')
// fragment with line feed
components = URI.parse('#\n')
components = fastURI.parse('#\n')
t.equal(components.error, undefined, 'path errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -116,7 +115,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, '%0A', 'fragment')
// fragment with line tabulation
components = URI.parse('#\v')
components = fastURI.parse('#\v')
t.equal(components.error, undefined, 'path errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -128,7 +127,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, '%0B', 'fragment')
// fragment with form feed
components = URI.parse('#\f')
components = fastURI.parse('#\f')
t.equal(components.error, undefined, 'path errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -140,7 +139,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, '%0C', 'fragment')
// fragment with carriage return
components = URI.parse('#\r')
components = fastURI.parse('#\r')
t.equal(components.error, undefined, 'path errors')
t.equal(components.scheme, undefined, 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -152,7 +151,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, '%0D', 'fragment')
// all
components = URI.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
components = fastURI.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
t.equal(components.error, undefined, 'all errors')
t.equal(components.scheme, 'uri', 'scheme')
// t.equal(components.authority, "user:pass@example.com:123", "authority");
@@ -164,7 +163,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, 'body', 'fragment')
// IPv4address
components = URI.parse('//10.10.10.10')
components = fastURI.parse('//10.10.10.10')
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -174,19 +173,28 @@ test('URI parse', (t) => {
t.equal(components.query, undefined, 'query')
t.equal(components.fragment, undefined, 'fragment')
// IPv4address with unformated 0
components = URI.parse('//10.10.000.10')
// IPv4address with unformated 0 stay as-is
components = fastURI.parse('//10.10.000.10') // not valid as per https://datatracker.ietf.org/doc/html/rfc5954#section-4.1
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
t.equal(components.host, '10.10.0.10', 'host')
t.equal(components.host, '10.10.000.10', 'host')
t.equal(components.port, undefined, 'port')
t.equal(components.path, '', 'path')
t.equal(components.query, undefined, 'query')
t.equal(components.fragment, undefined, 'fragment')
components = fastURI.parse('//01.01.01.01') // not valid in URIs: https://datatracker.ietf.org/doc/html/rfc3986#section-7.4
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
t.equal(components.host, '01.01.01.01', 'host')
t.equal(components.port, undefined, 'port')
t.equal(components.path, '', 'path')
t.equal(components.query, undefined, 'query')
t.equal(components.fragment, undefined, 'fragment')
// IPv6address
components = URI.parse('//[2001:db8::7]')
components = fastURI.parse('//[2001:db8::7]')
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -197,11 +205,11 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// invalid IPv6
components = URI.parse('//[2001:dbZ::7]')
components = fastURI.parse('//[2001:dbZ::7]')
t.equal(components.host, '[2001:dbz::7]')
// mixed IPv4address & IPv6address
components = URI.parse('//[::ffff:129.144.52.38]')
components = fastURI.parse('//[::ffff:129.144.52.38]')
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -212,7 +220,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
components = URI.parse('uri://10.10.10.10.example.com/en/process')
components = fastURI.parse('uri://10.10.10.10.example.com/en/process')
t.equal(components.error, undefined, 'mixed errors')
t.equal(components.scheme, 'uri', 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -223,7 +231,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// IPv6address, example from bkw (https://github.com/garycourt/uri-js/pull/16)
components = URI.parse('//[2606:2800:220:1:248:1893:25c8:1946]/test')
components = fastURI.parse('//[2606:2800:220:1:248:1893:25c8:1946]/test')
t.equal(components.error, undefined, 'IPv6address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -234,7 +242,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// IPv6address, example from RFC 5952
components = URI.parse('//[2001:db8::1]:80')
components = fastURI.parse('//[2001:db8::1]:80')
t.equal(components.error, undefined, 'IPv6address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -245,7 +253,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// IPv6address with zone identifier, RFC 6874
components = URI.parse('//[fe80::a%25en1]')
components = fastURI.parse('//[fe80::a%25en1]')
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -256,7 +264,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// IPv6address with an unescaped interface specifier, example from pekkanikander (https://github.com/garycourt/uri-js/pull/22)
components = URI.parse('//[2001:db8::7%en0]')
components = fastURI.parse('//[2001:db8::7%en0]')
t.equal(components.error, undefined, 'IPv6address interface errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
@@ -267,7 +275,7 @@ test('URI parse', (t) => {
t.equal(components.fragment, undefined, 'fragment')
// UUID V1
components = URI.parse('urn:uuid:b571b0bc-4713-11ec-81d3-0242ac130003')
components = fastURI.parse('urn:uuid:b571b0bc-4713-11ec-81d3-0242ac130003')
t.equal(components.error, undefined, 'errors')
t.equal(components.scheme, 'urn', 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -282,13 +290,13 @@ test('URI parse', (t) => {
t.equal(components.uuid, 'b571b0bc-4713-11ec-81d3-0242ac130003', 'uuid')
// UUID v4
components = URI.parse('urn:uuid:97a32222-89b7-420e-8507-4360723e2c2a')
components = fastURI.parse('urn:uuid:97a32222-89b7-420e-8507-4360723e2c2a')
t.equal(components.uuid, '97a32222-89b7-420e-8507-4360723e2c2a', 'uuid')
components = URI.parse('urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
components = fastURI.parse('urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
t.notSame(components.error, undefined, 'errors')
components = URI.parse('urn:foo:a123,456')
components = fastURI.parse('urn:foo:a123,456')
t.equal(components.error, undefined, 'errors')
t.equal(components.scheme, 'urn', 'scheme')
// t.equal(components.authority, undefined, "authority");
@@ -301,10 +309,10 @@ test('URI parse', (t) => {
t.equal(components.nid, 'foo', 'nid')
t.equal(components.nss, 'a123,456', 'nss')
components = URI.parse('//[2606:2800:220:1:248:1893:25c8:1946:43209]')
components = fastURI.parse('//[2606:2800:220:1:248:1893:25c8:1946:43209]')
t.equal(components.host, '[2606:2800:220:1:248:1893:25c8:1946:43209]')
components = URI.parse('urn:foo:|\\24fpl')
components = fastURI.parse('urn:foo:|\\24fpl')
t.equal(components.error, 'URN can not be parsed.')
t.end()
})