fix(client): prevent go to local links in preview
parent
d13cb03810
commit
a4dafdf54f
|
@ -25,6 +25,24 @@ const createHeader = (id = mainId) => `
|
|||
window.__err = err;
|
||||
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>
|
||||
`;
|
||||
|
||||
|
|
Loading…
Reference in New Issue