mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix network-form block explorer URL validation (#7137)
This commit is contained in:
parent
7af902e500
commit
869c83fd2c
@ -222,6 +222,17 @@ export default class NetworkForm extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateBlockExplorerUrl = (url, stateKey) => {
|
||||||
|
if (url === '' || validUrl.isWebUri(url)) {
|
||||||
|
this.setErrorTo(stateKey, '')
|
||||||
|
} else {
|
||||||
|
const appendedRpc = `http://${url}`
|
||||||
|
const validWhenAppended = validUrl.isWebUri(appendedRpc) && !url.match(/^https?:\/\/$/)
|
||||||
|
|
||||||
|
this.setErrorTo(stateKey, this.context.t(validWhenAppended ? 'uriErrorMsg' : 'invalidRPC'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { t } = this.context
|
const { t } = this.context
|
||||||
const {
|
const {
|
||||||
@ -272,7 +283,7 @@ export default class NetworkForm extends PureComponent {
|
|||||||
{this.renderFormTextField(
|
{this.renderFormTextField(
|
||||||
'blockExplorerUrl',
|
'blockExplorerUrl',
|
||||||
'block-explorer-url',
|
'block-explorer-url',
|
||||||
this.setStateWithValue('blockExplorerUrl', this.validateUrl),
|
this.setStateWithValue('blockExplorerUrl', this.validateBlockExplorerUrl),
|
||||||
blockExplorerUrl,
|
blockExplorerUrl,
|
||||||
'optionalBlockExplorerUrl',
|
'optionalBlockExplorerUrl',
|
||||||
)}
|
)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user