Skip to content

Commit 4e34cd4

Browse files
committed
fix(popup): don't crash on malformed urls
1 parent 6f3dd81 commit 4e34cd4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

popup/popup.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,13 @@ let $hoverLink = document.createElement('div');
388388
$hoverLink.className = 'mouseover-link';
389389
const hoverLinks = ($video) => {
390390
for (let $link of $video.querySelectorAll('a')) {
391-
let url = decodeURIComponent($link.href)
392-
.replace(/^https?:\/\/(www\.)?/, '');
391+
let href = $link.href;
392+
try {
393+
href = decodeURIComponent(href);
394+
} catch (err) {
395+
// do nothing
396+
}
397+
let url = href.replace(/^https?:\/\/(www\.)?/, '');
393398
if ($link.target === '_blank') { url += ' ⇗'; }
394399
$link.addEventListener('mouseover', (e) => {
395400
e.stopPropagation();

0 commit comments

Comments
 (0)