Commit de24e594e99f9352ee3679a960c1a20af79c6882
Ensure invalid URLs don't throw uncaught errors
Christian Bundy committed on 1/17/2019, 11:14:54 PMParent: fbe028b6ac554de8d22cdc41863da9342077a092
Files changed
app/async/catch-link-click.js | changed |
app/async/catch-link-click.js | ||
---|---|---|
@@ -30,9 +30,17 @@ | ||
30 | 30 … | |
31 | 31 … | var href = anchor.getAttribute('href') |
32 | 32 … | if (!href || href === '#') return |
33 | 33 … | |
34 | - var url = new URL(href) | |
34 … | + var url | |
35 … | + | |
36 … | + try { | |
37 … | + var url = new URL(href) | |
38 … | + } catch (e) { | |
39 … | + // In case we pass an invalid URL | |
40 … | + url = {} | |
41 … | + } | |
42 … | + | |
35 | 43 … | var opts = { |
36 | 44 … | altKey: ev.altKey, |
37 | 45 … | ctrlKey: ev.ctrlKey, |
38 | 46 … | metaKey: ev.metaKey, |
Built with git-ssb-web