Skip to content

Commit

Permalink
TxUtils: use regex to check for valid domain
Browse files Browse the repository at this point in the history
  • Loading branch information
selsta committed Nov 13, 2023
1 parent bea3032 commit ed2cc6b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions js/TxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ 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 ed2cc6b

Please sign in to comment.