summaryrefslogtreecommitdiff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/router.js5
-rw-r--r--app/lib/static.js4
2 files changed, 5 insertions, 4 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);
diff --git a/app/lib/static.js b/app/lib/static.js
index 26fc231..08c877f 100644
--- a/app/lib/static.js
+++ b/app/lib/static.js
@@ -1,5 +1,5 @@
import {normalize, extname} from "node:path";
-import {parse as parseURL} from "node:url";
+import {URL} from "node:url";
import fs from "node:fs";
const mimeTypes = {
@@ -46,7 +46,7 @@ export default class Static {
return;
}
- const pathname = parseURL(req.url).pathname;
+ const pathname = new URL(req.url, "file:").pathname; // TODO double-check
const sane = normalize(pathname).replace(/^(\.\.\/)+/, "");
let path = `${this.root}${sane}`; //Path.join(__dirname, sane);