forked from zed-industries/zed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove 2 removal (zed-industries#11867)
Release Notes: - N/A
- Loading branch information
1 parent
247825b
commit b7cf304
Showing
2 changed files
with
18 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
/** | ||
* Welcome to Cloudflare Workers! This is your first worker. | ||
* | ||
* - Run "npm run dev" in your terminal to start a development server | ||
* - Open a browser tab at http://localhost:8787/ to see your worker in action | ||
* - Run "npm run deploy" to publish your worker | ||
* | ||
* Learn more at https://developers.cloudflare.com/workers/ | ||
*/ | ||
export default { | ||
async fetch(request, env) { | ||
const url = new URL(request.url); | ||
const key = url.pathname.slice(1).replace(/2$/, ''); | ||
async fetch(request, env) { | ||
const url = new URL(request.url); | ||
const key = url.pathname.slice(1); | ||
|
||
const object = await env.OPEN_SOURCE_WEBSITE_ASSETS_BUCKET.get(key); | ||
if (!object) { | ||
return await fetch('https://zed.dev/404'); | ||
} | ||
const object = await env.OPEN_SOURCE_WEBSITE_ASSETS_BUCKET.get(key); | ||
if (!object) { | ||
return await fetch("https://zed.dev/404"); | ||
} | ||
|
||
const headers = new Headers(); | ||
object.writeHttpMetadata(headers); | ||
headers.set('etag', object.httpEtag); | ||
const headers = new Headers(); | ||
object.writeHttpMetadata(headers); | ||
headers.set("etag", object.httpEtag); | ||
|
||
return new Response(object.body, { | ||
headers, | ||
}); | ||
}, | ||
return new Response(object.body, { | ||
headers, | ||
}); | ||
}, | ||
}; |