mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
24 lines
545 B
JavaScript
24 lines
545 B
JavaScript
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}`);
|
|
},
|
|
};
|