test path-to-regexp

This commit is contained in:
xion 2025-03-16 23:54:57 +08:00
parent e8f7f61e09
commit 0e30dfc6ea

View File

@ -0,0 +1,13 @@
import { pathToRegexp } from 'path-to-regexp';
// import { match } from 'path-to-regexp';
const pattern = pathToRegexp('/users/*splat');
const match = pattern.regexp.exec('/users/123/j/d/f');
console.log(match);
// const pattern = pathToRegexp('/users/:id');
// const match = pattern.regexp.exec('/users/123');
// console.log(match);
// const pattern = '/a/b/*splat';
// const matchPath = match(pattern);
// console.log(matchPath('/a/b/c'));