lien 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hook-registry.js +13 -2
- package/package.json +1 -1
package/lib/hook-registry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { METHODS } from "node:http";
|
|
2
|
-
import { pathToRegexp } from "path-to-regexp";
|
|
2
|
+
import { parse, pathToRegexp } from "path-to-regexp";
|
|
3
3
|
import Hooks from "./hooks.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -147,7 +147,18 @@ function compilePattern (url) {
|
|
|
147
147
|
if (/:([\w$]+)\(|\(\.\*\)/.test(url)) {
|
|
148
148
|
return compileCustomPattern(url);
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
const pattern = normalizePattern(url);
|
|
151
|
+
if (pattern.endsWith("/")) {
|
|
152
|
+
const parsed = parse(pattern);
|
|
153
|
+
const [token] = parsed.tokens;
|
|
154
|
+
// Let path-to-regexp supply the optional delimiter for literal paths.
|
|
155
|
+
if (parsed.tokens.length === 1 && token.type === "text" &&
|
|
156
|
+
token.value.length > 1 && !token.value.endsWith("//")) {
|
|
157
|
+
token.value = token.value.slice(0, -1);
|
|
158
|
+
}
|
|
159
|
+
return pathToRegexp(parsed);
|
|
160
|
+
}
|
|
161
|
+
return pathToRegexp(pattern);
|
|
151
162
|
}
|
|
152
163
|
|
|
153
164
|
/**
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"test:coverage": "node --test --test-timeout=15000 --experimental-test-coverage test/*.test.js"
|
|
5
5
|
},
|
|
6
6
|
"name": "lien",
|
|
7
|
-
"version": "5.0.
|
|
7
|
+
"version": "5.0.1",
|
|
8
8
|
"description": "An easy to use web framework for Node.js.",
|
|
9
9
|
"main": "lib/index.js",
|
|
10
10
|
"keywords": [
|