Skip to content

Commit 0bfe35d

Browse files
committed
test: custom regexp patterns in URL paths
1 parent d1d0434 commit 0bfe35d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/chains/RouteMatchingProcessorChain.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ describe('RouteMatchingProcessorChain', () => {
6969
test(undefined, /\/user\/[0-9]+/, '/USER/1234', false, true);
7070
});
7171

72+
it('allows for custom regexp patterns in paths', () => {
73+
// https://github.com/pillarjs/path-to-regexp#custom-matching-parameters
74+
const PATTERN = '/:prefix(([A-Z]{1,3}-)?)users/:id';
75+
76+
test('GET', PATTERN, '/ABC-users/1234', true);
77+
test('GET', PATTERN, '/AB-users/1234', true);
78+
test('GET', PATTERN, '/A-users/1234', true);
79+
test('GET', PATTERN, '/users/1234', true);
80+
test('GET', PATTERN, '/ABCD-users/1234', false);
81+
});
82+
7283
});
7384

7485
const makePathAndParamsTests = (test: (routes: PathParams, path: string, expectation: StringMap) => void): () => void => {

0 commit comments

Comments
 (0)