mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix document extension check when injecting web3
This commit is contained in:
parent
8c33c018de
commit
d44b7ef3da
@ -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 () {
|
function suffixCheck () {
|
||||||
var prohibitedTypes = ['xml', 'pdf']
|
const prohibitedTypes = [
|
||||||
var currentUrl = window.location.href
|
/\.xml$/,
|
||||||
var currentRegex
|
/\.pdf$/,
|
||||||
|
]
|
||||||
|
const currentUrl = window.location.pathname
|
||||||
for (let i = 0; i < prohibitedTypes.length; i++) {
|
for (let i = 0; i < prohibitedTypes.length; i++) {
|
||||||
currentRegex = new RegExp(`\\.${prohibitedTypes[i]}$`)
|
if (prohibitedTypes[i].test(currentUrl)) {
|
||||||
if (currentRegex.test(currentUrl)) {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user