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,7 +1,6 @@
'use strict'
const t = require('tap')
const test = t.test
const { test } = require('node:test')
const FindMyWay = require('..')
test('Decode the URL before the routing', t => {
@@ -17,14 +16,14 @@ test('Decode the URL before the routing', t => {
findMyWay.on('GET', '/[...]/a%20.html', percentTwenty)
findMyWay.on('GET', '/[...]/a%2520.html', percentTwentyfive)
t.equal(findMyWay.find('GET', '/[...]/a .html').handler, space)
t.equal(findMyWay.find('GET', '/%5B...%5D/a .html').handler, space)
t.equal(findMyWay.find('GET', '/[...]/a%20.html').handler, space, 'a%20 decode is a ')
t.equal(findMyWay.find('GET', '/%5B...%5D/a%20.html').handler, space, 'a%20 decode is a ')
t.equal(findMyWay.find('GET', '/[...]/a%2520.html').handler, percentTwenty, 'a%2520 decode is a%20')
t.equal(findMyWay.find('GET', '/%5B...%5D/a%252520.html').handler, percentTwentyfive, 'a%252520.html is a%2520')
t.equal(findMyWay.find('GET', '/[...]/a .html'), null, 'double space')
t.equal(findMyWay.find('GET', '/static/%25E0%A4%A'), null, 'invalid encoded path param')
t.assert.equal(findMyWay.find('GET', '/[...]/a .html').handler, space)
t.assert.equal(findMyWay.find('GET', '/%5B...%5D/a .html').handler, space)
t.assert.equal(findMyWay.find('GET', '/[...]/a%20.html').handler, space, 'a%20 decode is a ')
t.assert.equal(findMyWay.find('GET', '/%5B...%5D/a%20.html').handler, space, 'a%20 decode is a ')
t.assert.equal(findMyWay.find('GET', '/[...]/a%2520.html').handler, percentTwenty, 'a%2520 decode is a%20')
t.assert.equal(findMyWay.find('GET', '/%5B...%5D/a%252520.html').handler, percentTwentyfive, 'a%252520.html is a%2520')
t.assert.equal(findMyWay.find('GET', '/[...]/a .html'), null, 'double space')
t.assert.equal(findMyWay.find('GET', '/static/%25E0%A4%A'), null, 'invalid encoded path param')
})
test('double encoding', t => {
@@ -32,16 +31,16 @@ test('double encoding', t => {
const findMyWay = FindMyWay()
function pathParam (req, res, params) {
t.same(params, this.expect, 'path param')
t.same(pathParam, this.handler, 'match handler')
t.assert.deepEqual(params, this.expect, 'path param')
t.assert.deepEqual(pathParam, this.handler, 'match handler')
}
function regexPathParam (req, res, params) {
t.same(params, this.expect, 'regex param')
t.same(regexPathParam, this.handler, 'match handler')
t.assert.deepEqual(params, this.expect, 'regex param')
t.assert.deepEqual(regexPathParam, this.handler, 'match handler')
}
function wildcard (req, res, params) {
t.same(params, this.expect, 'wildcard param')
t.same(wildcard, this.handler, 'match handler')
t.assert.deepEqual(params, this.expect, 'wildcard param')
t.assert.deepEqual(wildcard, this.handler, 'match handler')
}
findMyWay.on('GET', '/:pathParam', pathParam)
@@ -74,16 +73,16 @@ test('Special chars on path parameter', t => {
const findMyWay = FindMyWay()
function pathParam (req, res, params) {
t.same(params, this.expect, 'path param')
t.same(pathParam, this.handler, 'match handler')
t.assert.deepEqual(params, this.expect, 'path param')
t.assert.deepEqual(pathParam, this.handler, 'match handler')
}
function regexPathParam (req, res, params) {
t.same(params, this.expect, 'regex param')
t.same(regexPathParam, this.handler, 'match handler')
t.assert.deepEqual(params, this.expect, 'regex param')
t.assert.deepEqual(regexPathParam, this.handler, 'match handler')
}
function staticEncoded (req, res, params) {
t.same(params, this.expect, 'static match')
t.same(staticEncoded, this.handler, 'match handler')
t.assert.deepEqual(params, this.expect, 'static match')
t.assert.deepEqual(staticEncoded, this.handler, 'match handler')
}
findMyWay.on('GET', '/:pathParam', pathParam)
@@ -101,12 +100,12 @@ test('Multi parametric route with encoded colon separator', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.fail('Should not be defaultRoute')
t.assert.fail('Should not be defaultRoute')
}
})
findMyWay.on('GET', '/:param(.*)::suffix', (req, res, params) => {
t.equal(params.param, 'foo-bar')
t.assert.equal(params.param, 'foo-bar')
})
findMyWay.lookup({ method: 'GET', url: '/foo-bar%3Asuffix', headers: {} }, null)