Skip to content

Commit

Permalink
[Dev -> Stage] Parse URL before trying to find non-prod data (#216) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
apganapa-adobe authored Jan 10, 2025
2 parents afd0fe8 + e8cfc10 commit f249a87
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion events/scripts/content-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,17 @@ export async function getNonProdData(env) {
const json = await resp.json();
let { pathname } = window.location;
if (pathname.endsWith('.html')) pathname = pathname.slice(0, -5);
const pageData = json.data.find((d) => d.url === pathname);
const pageData = json.data.find((d) => {
let pageUrl = '';

try {
pageUrl = new URL(d.url).pathname;
} catch (e) {
pageUrl = d.url;
}

return pageUrl === pathname;
});

if (pageData) return pageData;

Expand Down

0 comments on commit f249a87

Please sign in to comment.