parent
e574524b9c
commit
7d0e77d86f
|
@ -52,7 +52,8 @@ QObject {
|
|||
readonly property var flatNetworks: root.walletRootStore.filteredFlatModel
|
||||
|
||||
function validatePairingUri(uri) {
|
||||
if(Helpers.containsOnlyEmoji(uri)) {
|
||||
// Check if emoji inside the URI
|
||||
if(Constants.regularExpressions.emoji.test(uri)) {
|
||||
root.pairingValidated(Pairing.errors.tooCool)
|
||||
return
|
||||
} else if(!Helpers.validURI(uri)) {
|
||||
|
|
|
@ -69,18 +69,13 @@ function buildSupportedNamespaces(chainIds, addresses, methods) {
|
|||
}
|
||||
|
||||
function validURI(uri) {
|
||||
var regex = /^wc:[0-9a-fA-F-]*@([1-9][0-9]*)(\?([a-zA-Z-]+=[^&]+)(&[a-zA-Z-]+=[^&]+)*)?$/
|
||||
const regex = /^wc:[0-9a-fA-F-]*@([1-9][0-9]*)(\?([a-zA-Z-]+=[^&]+)(&[a-zA-Z-]+=[^&]+)*)?$/
|
||||
return regex.test(uri)
|
||||
}
|
||||
|
||||
function containsOnlyEmoji(uri) {
|
||||
var emojiRegex = new RegExp("[\\u203C-\\u3299\\u1F000-\\u1F644]");
|
||||
return !emojiRegex.test(uri);
|
||||
}
|
||||
|
||||
function extractInfoFromPairUri(uri) {
|
||||
var topic = ""
|
||||
var expiry = NaN
|
||||
let topic = ""
|
||||
let expiry = NaN
|
||||
// Extract topic and expiry from wc:99fdcac5cc081ac8c1181b4c38c5dc49fb5eb212706d5c94c445be549765e7f0@2?expiryTimestamp=1720090818&relay-protocol=irn&symKey=c6b67d94174bd42d16ff288220ce9b8966e5b56a2d3570a30d5b0a760f1953f0
|
||||
const regex = /wc:([0-9a-fA-F]*)/
|
||||
const match = uri.match(regex)
|
||||
|
@ -88,11 +83,11 @@ function extractInfoFromPairUri(uri) {
|
|||
topic = match[1]
|
||||
}
|
||||
|
||||
var parts = uri.split('?')
|
||||
let parts = uri.split('?')
|
||||
if (parts.length > 1) {
|
||||
var params = parts[1].split('&')
|
||||
const params = parts[1].split('&')
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
var keyVal = params[i].split('=')
|
||||
const keyVal = params[i].split('=')
|
||||
if (keyVal[0] === 'expiryTimestamp') {
|
||||
expiry = parseInt(keyVal[1])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue