fix(client): prevent go to local links in preview
This commit is contained in:
committed by
mrugesh mohapatra
parent
d13cb03810
commit
a4dafdf54f
@ -25,6 +25,24 @@ const createHeader = (id = mainId) => `
|
|||||||
window.__err = err;
|
window.__err = err;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
let element = e.target;
|
||||||
|
while(element && element.nodeName !== 'A') {
|
||||||
|
element = element.parentElement;
|
||||||
|
}
|
||||||
|
if (element) {
|
||||||
|
const href = element.getAttribute('href');
|
||||||
|
if (!href || href[0] !== '#' && !href.match(/^https?:\\/\\//)) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
document.addEventListener('submit', function(e) {
|
||||||
|
const action = e.target.getAttribute('action');
|
||||||
|
if (!action || !action.match(/https?:\\/\\//)) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
</script>
|
</script>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user