summaryrefslogtreecommitdiff
path: root/app/lib/router.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/router.js')
-rw-r--r--app/lib/router.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/lib/router.js b/app/lib/router.js
index 186e6ad..7d30ccf 100644
--- a/app/lib/router.js
+++ b/app/lib/router.js
@@ -1,4 +1,4 @@
-import {parse as parseURL} from "node:url";
+import {URL} from "node:url";
const degroup = path => Object.assign(path, path.groups);
export default class Router {
@@ -7,7 +7,7 @@ export default class Router {
}
route(req, res) {
- const pathname = parseURL(req.url).pathname;
+ const pathname = new URL(req.url, "file:").pathname; // TODO double-check
return this.routes.some(route => {
const isMatch = route.method === req.method && route.re.test(pathname);
if (isMatch) route.cb(req, res, degroup(route.re.exec(pathname)));
@@ -30,6 +30,7 @@ export default class Router {
}
jpost(re, cb, max) {
+ // TODO check req content-type? set accepts?
this.gpost(re, (req, res, match, data) => {
try {
data = JSON.parse(data);