mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
Fix "/" in example
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
const { serve, file, resolveSync } = Bun;
|
||||
const { path } = import.meta;
|
||||
import { file } from "bun";
|
||||
|
||||
serve({
|
||||
fetch(req: Request) {
|
||||
return new Response(file(new URL(req.url).pathname.substring(1)));
|
||||
const pathname = new URL(req.url).pathname.substring(1);
|
||||
|
||||
// If the URL is empty, display this file.
|
||||
if (pathname === "") {
|
||||
return new Response(file(import.meta.url));
|
||||
}
|
||||
|
||||
return new Response(file(pathname));
|
||||
},
|
||||
|
||||
// this is called when fetch() throws or rejects
|
||||
|
||||
Reference in New Issue
Block a user