Skip to content

Commit

Permalink
changes from review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Sartxi committed Jun 19, 2024
1 parent d4a6ce6 commit 35dc59a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libs/blocks/locui/loc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ async function loadProjectSettings(projSettings) {
}

function sanitize(url) {
const hlxUrl = /^https?:\/\/[^/?#]+/g;
const [hostname] = url.match(hlxUrl);
const enDash = hostname.replaceAll('–', '--');
const newURL = url.replace(hlxUrl, enDash);
let newURL = url;
const matchHost = /^https?:\/\/[^/?#]+/g;
const [hostname] = url.match(matchHost);
if (hostname) {
const enDash = hostname.replaceAll('–', '--');
newURL = url.replace(matchHost, enDash);
}
return new URL(newURL);
}

Expand All @@ -110,7 +113,7 @@ async function loadDetails() {
try {
const resp = await fetch(previewPath);
const json = await resp.json();
const jsonUrls = json.urls.data.map(({ URL }) => sanitize(URL));
const jsonUrls = json.urls.data.map((item) => sanitize(item.URL));
const projectUrls = getUrls(jsonUrls);
const projectLangs = json.languages.data.reduce((rdx, lang) => {
if (LANG_ACTIONS.includes(lang.Action)) {
Expand Down

0 comments on commit 35dc59a

Please sign in to comment.