From 78f634726f0460dbbc1cbb4d98d620f9f1a817b8 Mon Sep 17 00:00:00 2001 From: Ng Guoyou Date: Fri, 21 Apr 2017 02:52:44 +0800 Subject: [PATCH] Fix link/media detection, strip bad characters from filenames --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 0428f20..0b8da58 100644 --- a/src/index.js +++ b/src/index.js @@ -43,8 +43,8 @@ browser.contextMenus.onClicked.addListener((info) => { if (matchSave && matchSave.length === 2) { const path = matchSave[1]; - const url = MEDIA_TYPES.includes('info.mediaType') ? info.srcUrl : info.linkUrl; - const filename = url.substring(url.lastIndexOf('/') + 1); + const url = MEDIA_TYPES.includes(info.mediaType) ? info.srcUrl : info.linkUrl; + const filename = url.substring(url.lastIndexOf('/') + 1).replace(/[|&;$%@"<>()+,]/g, ''); browser.downloads.download({ url,