Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MWPW-153611] [Gray Box] environment aware links #2622

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libs/blocks/graybox/graybox.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,16 @@
}
};

const transformLinks = () => {
const grayboxHostname = window.location.hostname;
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
const consumerHostname = grayboxHostname.replace(/[^.]+\.(?:([^.]+)-)?graybox\./, (_, sub) => `${sub || 'www'}.`);
document.querySelectorAll(`a[href*="${consumerHostname}"]`).forEach((el) => {
el.href = el.href.replace(consumerHostname, grayboxHostname);

Check warning on line 271 in libs/blocks/graybox/graybox.js

View check run for this annotation

Codecov / codecov/patch

libs/blocks/graybox/graybox.js#L271

Added line #L271 was not covered by tests
});
};

const grayboxThePage = (grayboxEl, grayboxMenuOff) => () => {
transformLinks();
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
document.body.classList.add(CLASS.GRAYBOX_BODY);
const globalNoClick = grayboxEl.classList.contains(CLASS.NO_CLICK)
|| grayboxEl.classList.contains(OPTION.NO_CLICK);
Expand Down