Buckets:
| const { test } = require('node:test') | |
| const FindMyWay = require('../') | |
| test('Falling back for node\'s parametric brother without ignoreTrailingSlash', t => { | |
| t.plan(4) | |
| const findMyWay = FindMyWay({ | |
| ignoreTrailingSlash: false, | |
| defaultRoute: (req, res) => { | |
| t.assert.fail('Should not be defaultRoute') | |
| } | |
| }) | |
| findMyWay.on('GET', '/static/param1', () => {}) | |
| findMyWay.on('GET', '/static/param2', () => {}) | |
| findMyWay.on('GET', '/static/:paramA/next', () => {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param2').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/paramOther/next').params, { paramA: 'paramOther' }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next').params, { paramA: 'param1' }) | |
| }) | |
| test('Falling back for node\'s parametric brother with ignoreTrailingSlash', t => { | |
| t.plan(4) | |
| const findMyWay = FindMyWay({ | |
| ignoreTrailingSlash: true, | |
| defaultRoute: (req, res) => { | |
| t.assert.fail('Should not be defaultRoute') | |
| } | |
| }) | |
| findMyWay.on('GET', '/static/param1', () => {}) | |
| findMyWay.on('GET', '/static/param2', () => {}) | |
| findMyWay.on('GET', '/static/:paramA/next', () => {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param2').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/paramOther/next').params, { paramA: 'paramOther' }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next').params, { paramA: 'param1' }) | |
| }) | |
| test('Falling back for node\'s parametric brother without ignoreTrailingSlash', t => { | |
| t.plan(4) | |
| const findMyWay = FindMyWay({ | |
| ignoreTrailingSlash: false, | |
| defaultRoute: (req, res) => { | |
| t.assert.fail('Should not be defaultRoute') | |
| } | |
| }) | |
| findMyWay.on('GET', '/static/param1', () => {}) | |
| findMyWay.on('GET', '/static/param2', () => {}) | |
| findMyWay.on('GET', '/static/:paramA/next', () => {}) | |
| findMyWay.on('GET', '/static/param1/next/param3', () => {}) | |
| findMyWay.on('GET', '/static/param1/next/param4', () => {}) | |
| findMyWay.on('GET', '/static/:paramA/next/:paramB/other', () => {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next/param3').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next/param4').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/paramOther/next/paramOther2/other').params, { paramA: 'paramOther', paramB: 'paramOther2' }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next/param3/other').params, { paramA: 'param1', paramB: 'param3' }) | |
| }) | |
| test('Falling back for node\'s parametric brother with ignoreTrailingSlash', t => { | |
| t.plan(4) | |
| const findMyWay = FindMyWay({ | |
| ignoreTrailingSlash: true, | |
| defaultRoute: (req, res) => { | |
| t.assert.fail('Should not be defaultRoute') | |
| } | |
| }) | |
| findMyWay.on('GET', '/static/param1', () => {}) | |
| findMyWay.on('GET', '/static/param2', () => {}) | |
| findMyWay.on('GET', '/static/:paramA/next', () => {}) | |
| findMyWay.on('GET', '/static/param1/next/param3', () => {}) | |
| findMyWay.on('GET', '/static/param1/next/param4', () => {}) | |
| findMyWay.on('GET', '/static/:paramA/next/:paramB/other', () => {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next/param3').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next/param4').params, {}) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/paramOther/next/paramOther2/other').params, { paramA: 'paramOther', paramB: 'paramOther2' }) | |
| t.assert.deepEqual(findMyWay.find('GET', '/static/param1/next/param3/other').params, { paramA: 'param1', paramB: 'param3' }) | |
| }) | |
Xet Storage Details
- Size:
- 3.72 kB
- Xet hash:
- 38b0789d4548a47d1f4744871b709ec74ebc4cbb2b044c7d1e3c4b57665a391c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.