blob: 3c67f02c2e21ed35b91a1f067f0755d7e5570c74 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import { resolve } from "path";
import { parse } from "querystring";
export default {
fetch(req) {
if (req.url === "/favicon.ico") return new Response("nooo dont open favicon in editor", { status: 404 });
var pathname = req.url.substring(1);
const q = pathname.indexOf("?");
var { editor } = parse(pathname.substring(q + 1)) || {};
if (q > 0) {
pathname = pathname.substring(0, q);
}
Bun.openInEditor(resolve(pathname), {
editor,
});
return new Response(`Opened ${req.url}`);
},
};
|