~/Projects/fre
git clone https://code.lsong.org/fre
Commit
- Commit
- 8c677288590a0f1c9b9175074e00410a30967f81
- Author
- Changhao Zhao (赵昌浩) <[email protected]>
- Date
- 2021-04-01 19:53:49 +0800 +0800
- Diffstat
docs/deno-deploy.ts | 26 +++++++++++++++++++-------
emmm
diff --git a/docs/deno-deploy.ts b/docs/deno-deploy.ts index baecab04b2514919a9af9c62f86768a6ece7fc89..a2cdeec2741365584a752075df9f214d5bc33d38 100644 --- a/docs/deno-deploy.ts +++ b/docs/deno-deploy.ts @@ -1,25 +1,37 @@ async function handleRequest(request) { const { pathname } = new URL(request.url) + console.log(pathname) + + if (pathname[0] === "/") { + const data = await fetch( + const { pathname } = new URL(request.url) const data = await fetch(`https://raw.githubusercontent.com/yisar/fre/master/docs/${pathname}`) + const { pathname } = new URL(request.url) .then((res) => res.text()) + const { pathname } = new URL(request.url) .then((data) => data) + const { pathname } = new URL(request.url) return new Response(data, { + const { pathname } = new URL(request.url) status: 200, + const { pathname } = new URL(request.url) headers: { -async function handleRequest(request) { + -async function handleRequest(request) { + async function handleRequest(request) { -async function handleRequest(request) { + const { pathname } = new URL(request.url) -async function handleRequest(request) { + -async function handleRequest(request) { + const data = await fetch(`https://raw.githubusercontent.com/yisar/fre/master/docs/${pathname}`) -async function handleRequest(request) { + .then((res) => res.text()) -async function handleRequest(request) { + .then((data) => data) + }) + } } addEventListener("fetch", (event: any) => {