Atualização automática: 2026-05-18 20:04:24

This commit is contained in:
Hermes
2026-05-18 20:04:24 +00:00
parent 1972b016a8
commit 37612a7b81
+10 -4
View File
@@ -142,11 +142,17 @@ app.use((req, res, next) => {
try {
let jsContent = fs.readFileSync(filePath, 'utf8');
// Substitui chamadas diretas a window.location.pathname ou location.pathname em uma única passagem limpa
jsContent = jsContent.replace(/(?:window\.)?location\.pathname/g, '(window.__mockLocationPathname || window.location.pathname)');
// Substitui window.location.pathname de forma segura
jsContent = jsContent.replace(/\bwindow\.location\.pathname\b/g, '(window.__mockLocationPathname || window.location.pathname)');
// Substitui chamadas diretas a window.location.href ou location.href em uma única passagem limpa
jsContent = jsContent.replace(/(?:window\.)?location\.href/g, '(window.__mockLocationHref || window.location.href)');
// Substitui location.pathname isolado (evita quebrar e.location.pathname ou history.location.pathname)
jsContent = jsContent.replace(/(?<!\w\.)\blocation\.pathname\b/g, '(window.__mockLocationPathname || window.location.pathname)');
// Substitui window.location.href de forma segura
jsContent = jsContent.replace(/\bwindow\.location\.href\b/g, '(window.__mockLocationHref || window.location.href)');
// Substitui location.href isolado (evita quebrar e.location.href ou history.location.href)
jsContent = jsContent.replace(/(?<!\w\.)\blocation\.href\b/g, '(window.__mockLocationHref || window.location.href)');
res.setHeader('Content-Type', 'application/javascript');
return res.send(jsContent);