Skip to content

Commit

Permalink
MWPW-156094: clean up LTRM in URLs (#2718)
Browse files Browse the repository at this point in the history
MWPW-156094: Unicode sequence %E2%80%8E is being added after il_he country code for MIQ json files | UAR | Milo
  • Loading branch information
JackySun9 authored Aug 13, 2024
1 parent 2091558 commit cf166ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion libs/blocks/quiz/quizcontainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { html } from '../../deps/htm-preact.js';
import { removeLeftToRightMark } from './utils.js';

export const DecorateBlockBackgroundCmp = ({ background = '' }) => html`<img loading="eager" alt="" src=${background} height="1020" width="1920" />`;
export const DecorateBlockBackgroundCmp = ({ background = '' }) => html`<img loading="eager" alt="" src=${removeLeftToRightMark(background)} height="1020" width="1920" />`;

export const DecorateBlockForeground = ({ heading, subhead }) => html`<div class="quiz-foreground">
<h1 id="question" class="quiz-question-title" daa-lh="${heading}">${heading}</h1>
Expand Down
9 changes: 5 additions & 4 deletions libs/blocks/quiz/quizoption.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { html } from '../../deps/htm-preact.js';
import { removeLeftToRightMark } from './utils.js';

export const OptionCard = ({
text, title, image, icon, iconTablet, iconDesktop, options, disabled, selected, background,
Expand All @@ -22,15 +23,15 @@ export const OptionCard = ({

const getIconHtml = () => html`<div class="quiz-option-icon ${getIconClass()}">
<picture>
${iconDesktop && html`<source media="(min-width: 1024px)" srcset="${iconDesktop}" />`}
${iconTablet && html`<source media="(min-width: 600px)" srcset="${iconTablet}" />`}
<img src="${icon}" alt="" loading="lazy" />
${iconDesktop && html`<source media="(min-width: 1024px)" srcset="${removeLeftToRightMark(iconDesktop)}" />`}
${iconTablet && html`<source media="(min-width: 600px)" srcset="${removeLeftToRightMark(iconTablet)}" />`}
<img src="${removeLeftToRightMark(icon)}" alt="" loading="lazy" />
</picture>
</div>`;

const imageHtml = html`
<div class="quiz-option-image"
style="background-image: url('${image}'); background-size: cover" loading="lazy">
style="background-image: url('${removeLeftToRightMark(image)}'); background-size: cover" loading="lazy">
</div>`;

const titleHtml = html`
Expand Down
5 changes: 4 additions & 1 deletion libs/blocks/quiz/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,11 @@ export const isValidUrl = (url) => VALID_URL_RE.test(url);

export const getNormalizedMetadata = (el) => normalizeKeys(getMetadata(el));

export const removeLeftToRightMark = (url) => decodeURIComponent(url).replace(/\u200E/g, '');

export const getLocalizedURL = (originalURL) => {
const { locale } = getConfig();
const { prefix, ietf = 'en-US' } = locale || {};
return ietf !== 'en-US' && !originalURL.startsWith(`${prefix}/`) ? `${prefix}${originalURL}` : originalURL;
const decodedURL = removeLeftToRightMark(originalURL);
return ietf !== 'en-US' && !decodedURL.startsWith(`${prefix}/`) ? `${prefix}${decodedURL}` : decodedURL;
};

0 comments on commit cf166ca

Please sign in to comment.