From 1cc10fcb4c4153bd9bdca1bce9f2cb7a1438edac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E5=8D=A1=E7=90=B3?= Date: Mon, 26 Feb 2018 16:47:06 +0800 Subject: [PATCH] Update downloadAble.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修复拼写错误 2. 提高效率 --- src/public/downloadAble.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/public/downloadAble.js b/src/public/downloadAble.js index a748aa1..c55198d 100644 --- a/src/public/downloadAble.js +++ b/src/public/downloadAble.js @@ -22,6 +22,11 @@ export default function downloadAble(url, config = {}, keypress = {}) { if(keypress.isShiftPressd){ return true } + + // 如果 pathname 没有".",提前返回false + if(!pathname.includes(".")){ + return false; + } //判断 pathname 中文件后缀是否在配置内 const pathname_lowercase = pathname.toLowerCase(); @@ -30,7 +35,7 @@ export default function downloadAble(url, config = {}, keypress = {}) { .toLowerCase() .split(/\s+/) .map(filetype => "." + filetype) - .some(ext => pathname_lowercase.endswith(ext)) + .some(ext => pathname_lowercase.endsWith(ext)) : false; }