aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-03-29 05:41:04 +0800
committerGitHub <noreply@github.com>2017-03-29 05:41:04 +0800
commit731f6654094fb6cac832d4092471c51b554a34d4 (patch)
treece78932b5b2ef8f41aa62bc7c61708df030c87e7
parent903d3aeb7a3482f9de1d43d5634bdfec59715288 (diff)
parent0625b4a11038307673a4fcd9689e0955e10ebacf (diff)
downloadtangerine-wallet-browser-731f6654094fb6cac832d4092471c51b554a34d4.tar
tangerine-wallet-browser-731f6654094fb6cac832d4092471c51b554a34d4.tar.gz
tangerine-wallet-browser-731f6654094fb6cac832d4092471c51b554a34d4.tar.bz2
tangerine-wallet-browser-731f6654094fb6cac832d4092471c51b554a34d4.tar.lz
tangerine-wallet-browser-731f6654094fb6cac832d4092471c51b554a34d4.tar.xz
tangerine-wallet-browser-731f6654094fb6cac832d4092471c51b554a34d4.tar.zst
tangerine-wallet-browser-731f6654094fb6cac832d4092471c51b554a34d4.zip
Merge pull request #1275 from MetaMask/injection-polish
Fix injection logic.
-rw-r--r--app/scripts/contentscript.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index 09c1841bf..9a390e580 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -65,14 +65,27 @@ function setupStreams () {
}
function shouldInjectWeb3 () {
- return isAllowedSuffix(window.location.href)
+ return doctypeCheck() || suffixCheck()
}
-function isAllowedSuffix (testCase) {
+function doctypeCheck () {
const doctype = window.document.doctype
if (doctype) {
return doctype.name === 'html'
} else {
- return true
+ return false
}
}
+
+function suffixCheck() {
+ var prohibitedTypes = ['xml', 'pdf']
+ var currentUrl = window.location.href
+ var currentRegex
+ for (let i = 0; i < prohibitedTypes.length; i++) {
+ currentRegex = new RegExp(`\.${prohibitedTypes[i]}$`)
+ if (currentRegex.test(currentUrl)) {
+ return false
+ }
+ }
+ return true
+}