修复路由一处bug

master 1.3.2
yutent 2023-12-27 10:58:37 +08:00
parent 1e08003ba7
commit 5136605322
2 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "wkitd", "name": "wkitd",
"version": "1.3.1", "version": "1.3.2",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
"files": [ "files": [

View File

@ -64,7 +64,7 @@ class Router {
re = route.path.replace( re = route.path.replace(
RULE_REGEXP, RULE_REGEXP,
function (m, _prefix, _var, _require) { function (m, _prefix, _var, _require = '') {
vars.push(_var.slice(1)) vars.push(_var.slice(1))
if (_prefix === '/') { if (_prefix === '/') {
_prefix = '/?' _prefix = '/?'
@ -116,6 +116,7 @@ class Router {
} }
for (let [k, route] of this.#tables) { for (let [k, route] of this.#tables) {
console.log(route, path.match(route.regexp))
let args = path.match(route.regexp) let args = path.match(route.regexp)
if (args) { if (args) {
let params = Object.create(null) let params = Object.create(null)