aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-10-16 08:26:51 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-10-16 21:38:48 +0800
commitd44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5 (patch)
tree5e8eab6ada24cffe10beac24809a443c489a88ec
parent8c33c018dead721d7ad3b86d75a8a7abcade3938 (diff)
downloadtangerine-wallet-browser-d44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5.tar
tangerine-wallet-browser-d44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5.tar.gz
tangerine-wallet-browser-d44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5.tar.bz2
tangerine-wallet-browser-d44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5.tar.lz
tangerine-wallet-browser-d44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5.tar.xz
tangerine-wallet-browser-d44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5.tar.zst
tangerine-wallet-browser-d44b7ef3da36d3d4c1d91fc779ecb9eb034c4ea5.zip
Fix document extension check when injecting web3
-rw-r--r--app/scripts/contentscript.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index d870741d6..33523eb46 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -135,17 +135,22 @@ function doctypeCheck () {
}
/**
- * Checks the current document extension
+ * Returns whether or not the extension (suffix) of the current document is prohibited
*
- * @returns {boolean} {@code true} if the current extension is not prohibited
+ * This checks {@code window.location.pathname} against a set of file extensions
+ * that should not have web3 injected into them. This check is indifferent of query parameters
+ * in the location.
+ *
+ * @returns {boolean} whether or not the extension of the current document is prohibited
*/
function suffixCheck () {
- var prohibitedTypes = ['xml', 'pdf']
- var currentUrl = window.location.href
- var currentRegex
+ const prohibitedTypes = [
+ /\.xml$/,
+ /\.pdf$/,
+ ]
+ const currentUrl = window.location.pathname
for (let i = 0; i < prohibitedTypes.length; i++) {
- currentRegex = new RegExp(`\\.${prohibitedTypes[i]}$`)
- if (currentRegex.test(currentUrl)) {
+ if (prohibitedTypes[i].test(currentUrl)) {
return false
}
}