blob: 30992d95898e3ecc7d5d12c0323c9d0151b6d6e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { resolve } from "path";
import { parse } from "querystring";
export default {
fetch(req) {
const url = new URL(req.url);
if (url.pathname === "/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}`);
},
};
|