Skip to content

Commit

Permalink
Merge pull request #1051 from OWASP/final-website-changes
Browse files Browse the repository at this point in the history
Ensure that when the card is requested with a lower case code, the card still is returned
  • Loading branch information
sydseter authored Feb 13, 2025
2 parents bee0ab2 + 13d792c commit ab769c9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cornucopia.owasp.org/script/nonce-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ async function fetchAndStreamNotFoundPage(resp) {
const host = pathArray[2];
const url = protocol + '//' + host + '/404';
const { headers } = resp;

const response = await fetch(url);

const html = (await response.text()).replace(/\.\//gi, '/').replace(/id="breadcrumbs" class="/gi, "id=\"breadcrumbs\" class=\"hide ");
let response;
let html;
if (resp.url.includes('/cards/') && (/[a-z]/.test(path))) {
response = await fetch(protocol + "//" + host + "/cards/" + path.toUpperCase());
html = (await response.text()).replace(/\.\.\//gi, "/")
} else {
response = await fetch(url);
html = (await response.text()).replace(/\.\//gi, "/").replace(/id="breadcrumbs" class="/gi, 'id="breadcrumbs" class="hide ');
}
return new Response(html, {
status: status,
statusText: statusText,
Expand Down

0 comments on commit ab769c9

Please sign in to comment.