refactor: early return (#389)

* refactor: early return

Undents all the code below it 1 level. Readability win.

---------

Co-authored-by: Brandon Liu <bdon@bdon.org>
This commit is contained in:
Niels Bom
2024-04-26 06:41:40 +02:00
committed by GitHub
parent 3b5ab6b7ac
commit 658c75b073

View File

@@ -101,7 +101,10 @@ export default {
const cache = caches.default; const cache = caches.default;
if (ok) { if (!ok) {
return new Response("Invalid URL", { status: 404 });
}
let allowedOrigin = ""; let allowedOrigin = "";
if (typeof env.ALLOWED_ORIGINS !== "undefined") { if (typeof env.ALLOWED_ORIGINS !== "undefined") {
for (const o of env.ALLOWED_ORIGINS.split(",")) { for (const o of env.ALLOWED_ORIGINS.split(",")) {
@@ -217,8 +220,5 @@ export default {
} }
throw e; throw e;
} }
}
return new Response("Invalid URL", { status: 404 });
}, },
}; };