bun-router 0.2.6 → 0.2.8
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/examples/space.ts +9 -0
- package/lib/router/router.ts +5 -1
- package/package.json +1 -1
package/lib/router/router.ts
CHANGED
@@ -72,7 +72,7 @@ const extractParams = (route: Route, req: HttpRequest) => {
|
|
72
72
|
}
|
73
73
|
|
74
74
|
const match = (route: Route, req: HttpRequest): boolean => {
|
75
|
-
return req.params.size !== 0 || route.
|
75
|
+
return req.params.size !== 0 || route.pattern === (new URL(req.request.url)).pathname
|
76
76
|
}
|
77
77
|
|
78
78
|
const router: Router = (port?: number | string, options?: Options) => {
|
@@ -101,6 +101,10 @@ const router: Router = (port?: number | string, options?: Options) => {
|
|
101
101
|
|
102
102
|
extractParams(route, httpRequest);
|
103
103
|
|
104
|
+
if (match(route, httpRequest))
|
105
|
+
return route.callback(httpRequest);
|
106
|
+
|
107
|
+
|
104
108
|
if (match(route, httpRequest)) return route.callback(httpRequest);
|
105
109
|
}
|
106
110
|
return new Response('not found');
|
package/package.json
CHANGED