Files
pulse-signage/src/web/routes/common.js
T

25 lines
568 B
JavaScript

// Shared route helpers for web view rendering and player URL formatting.
function escapeHtml(value) {
return String(value ?? '')
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
function screenPlayerUrl(slug, baseUrl) {
const normalizedBaseUrl = String(baseUrl || '').trim().replace(/\/$/, '');
if (!normalizedBaseUrl) {
return '';
}
return `${normalizedBaseUrl}/screen/${encodeURIComponent(slug)}`;
}
module.exports = {
escapeHtml,
screenPlayerUrl
};