aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/contentscript.js
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-10-17 02:01:54 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-10-17 02:01:54 +0800
commit13820b6cc1801a420f39cdfecd7ccb5309dc597b (patch)
treec79832d7077ab03e0afe0c322cb32b204865d8b5 /app/scripts/contentscript.js
parenteeecee01540fbad50c4c463a3b1a54142a63f168 (diff)
parent07ab613d4c647e3fe554bc06eab8cfb833315a88 (diff)
downloadtangerine-wallet-browser-13820b6cc1801a420f39cdfecd7ccb5309dc597b.tar
tangerine-wallet-browser-13820b6cc1801a420f39cdfecd7ccb5309dc597b.tar.gz
tangerine-wallet-browser-13820b6cc1801a420f39cdfecd7ccb5309dc597b.tar.bz2
tangerine-wallet-browser-13820b6cc1801a420f39cdfecd7ccb5309dc597b.tar.lz
tangerine-wallet-browser-13820b6cc1801a420f39cdfecd7ccb5309dc597b.tar.xz
tangerine-wallet-browser-13820b6cc1801a420f39cdfecd7ccb5309dc597b.tar.zst
tangerine-wallet-browser-13820b6cc1801a420f39cdfecd7ccb5309dc597b.zip
fix conflicts
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r--app/scripts/contentscript.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index 6eee1987a..33523eb46 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -1,6 +1,7 @@
const fs = require('fs')
const path = require('path')
const pump = require('pump')
+const querystring = require('querystring')
const LocalMessageDuplexStream = require('post-message-stream')
const PongStream = require('ping-pong-stream/pong')
const ObjectMultiplex = require('obj-multiplex')
@@ -134,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
}
}
@@ -199,5 +205,8 @@ function blacklistedDomainCheck () {
function redirectToPhishingWarning () {
console.log('MetaMask - routing to Phishing Warning component')
const extensionURL = extension.runtime.getURL('phishing.html')
- window.location.href = extensionURL
+ window.location.href = `${extensionURL}#${querystring.stringify({
+ hostname: window.location.hostname,
+ href: window.location.href,
+ })}`
}