Build Mission Core Promo around 15 applied solutions
This commit is contained in:
@@ -437,6 +437,15 @@ function withLandingTarget(html, block) {
|
||||
return `<span id="${escapeAttr(target)}" class="landing-target" aria-hidden="true"></span>${html}`;
|
||||
}
|
||||
|
||||
function safeArticleHref(value) {
|
||||
const href = typeof value === "string" ? value.trim() : "";
|
||||
if (!href || /[\u0000-\u001f\u007f]/.test(href)) return "";
|
||||
try {
|
||||
const url = new URL(href, "https://nodedc.ru/");
|
||||
return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password ? href : "";
|
||||
} catch { return ""; }
|
||||
}
|
||||
|
||||
async function renderBlock(block, renderCounts) {
|
||||
if (block.enabled === false) {
|
||||
return "";
|
||||
@@ -448,6 +457,8 @@ async function renderBlock(block, renderCounts) {
|
||||
block = { ...block, content: { mediaKind: "", note: "", modules: [], openImagesInFullscreen: false, ...block.content } };
|
||||
block.content.sliderItems = (block.content.sliderItems || []).map(item => ({
|
||||
description: "", imageSrc: "", imageAlt: "", videoSrc: "", posterSrc: "", ...item,
|
||||
detailsHref: safeArticleHref(item.detailsHref),
|
||||
detailsLabel: typeof item.detailsLabel === "string" && item.detailsLabel.trim() ? item.detailsLabel.trim() : "Подробнее",
|
||||
imageLinkEnabled: block.content.openImagesInFullscreen === true,
|
||||
imageLinkDisabled: block.content.openImagesInFullscreen !== true,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user