Skip to content

Commit

Permalink
Merge pull request #4243
Browse files Browse the repository at this point in the history
e41f3cf TxUtils: use regex to check for valid domain (selsta)
  • Loading branch information
luigi1111 committed Jan 18, 2024
2 parents e9cd458 + e41f3cf commit f284677
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/TxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ function checkSignature(signature) {
}

function isValidOpenAliasAddress(address) {
address = address.trim()
// we can get an awful lot of valid domains, including non ASCII chars... accept anything
// there should be something after the .
// make sure it is not some kind of floating number
return address.length > 2 && isNaN(parseFloat(address)) && address.indexOf('.') >= 0
var regex = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/; // Basic domain structure

if (!regex.test(address)) {
return false;
}

const lastPart = address.substring(address.lastIndexOf('.') + 1);
return isNaN(parseInt(lastPart)) || lastPart !== parseInt(lastPart).toString();
}

function handleOpenAliasResolution(address, descriptionText) {
Expand Down

0 comments on commit f284677

Please sign in to comment.