Skip to content

Commit 13d792c

Browse files
committed
Ensure that when the card is requested with a lower case code, the card still is returned
1 parent 668ce63 commit 13d792c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cornucopia.owasp.org/script/nonce-worker.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ async function fetchAndStreamNotFoundPage(resp) {
2424
const host = pathArray[2];
2525
const url = protocol + '//' + host + '/404';
2626
const { headers } = resp;
27-
28-
const response = await fetch(url);
29-
30-
const html = (await response.text()).replace(/\.\//gi, '/').replace(/id="breadcrumbs" class="/gi, "id=\"breadcrumbs\" class=\"hide ");
27+
let response;
28+
let html;
29+
if (resp.url.includes('/cards/') && (/[a-z]/.test(path))) {
30+
response = await fetch(protocol + "//" + host + "/cards/" + path.toUpperCase());
31+
html = (await response.text()).replace(/\.\.\//gi, "/")
32+
} else {
33+
response = await fetch(url);
34+
html = (await response.text()).replace(/\.\//gi, "/").replace(/id="breadcrumbs" class="/gi, 'id="breadcrumbs" class="hide ');
35+
}
3136
return new Response(html, {
3237
status: status,
3338
statusText: statusText,

0 commit comments

Comments
 (0)