mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 03:59:38 +00:00
TxUtils: use regex to check for valid domain
This commit is contained in:
parent
bea3032df9
commit
e41f3cfd13
1 changed files with 8 additions and 5 deletions
|
@ -70,11 +70,14 @@ function checkSignature(signature) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidOpenAliasAddress(address) {
|
function isValidOpenAliasAddress(address) {
|
||||||
address = address.trim()
|
var regex = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/; // Basic domain structure
|
||||||
// we can get an awful lot of valid domains, including non ASCII chars... accept anything
|
|
||||||
// there should be something after the .
|
if (!regex.test(address)) {
|
||||||
// make sure it is not some kind of floating number
|
return false;
|
||||||
return address.length > 2 && isNaN(parseFloat(address)) && address.indexOf('.') >= 0
|
}
|
||||||
|
|
||||||
|
const lastPart = address.substring(address.lastIndexOf('.') + 1);
|
||||||
|
return isNaN(parseInt(lastPart)) || lastPart !== parseInt(lastPart).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOpenAliasResolution(address, descriptionText) {
|
function handleOpenAliasResolution(address, descriptionText) {
|
||||||
|
|
Loading…
Reference in a new issue