mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix injection logic.
This commit is contained in:
parent
903d3aeb7a
commit
0625b4a110
@ -65,14 +65,27 @@ function setupStreams () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldInjectWeb3 () {
|
function shouldInjectWeb3 () {
|
||||||
return isAllowedSuffix(window.location.href)
|
return doctypeCheck() || suffixCheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAllowedSuffix (testCase) {
|
function doctypeCheck () {
|
||||||
const doctype = window.document.doctype
|
const doctype = window.document.doctype
|
||||||
if (doctype) {
|
if (doctype) {
|
||||||
return doctype.name === 'html'
|
return doctype.name === 'html'
|
||||||
} else {
|
} 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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user