Replace URL with URI

This commit is contained in:
Yarmo Mackenbach 2020-10-24 11:18:06 +02:00
parent ed2178b652
commit 43b16ffbaf
2 changed files with 18 additions and 18 deletions

View file

@ -1,16 +1,16 @@
const reURL = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
const reURI = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
const processURL = (url, opts) => {
const match = url.match(reURL)
const processURL = (uri, opts) => {
const match = uri.match(reURL)
return {
type: "domain",
profile: {
display: match[1],
url: `https://${match[1]}`
uri: `https://${match[1]}`
},
proof: {
url: `https://dns.shivering-isles.com/dns-query?name=${match[1]}&type=TXT`,
uri: `https://dns.shivering-isles.com/dns-query?name=${match[1]}&type=TXT`,
fetch: null
},
qr: null
@ -19,19 +19,19 @@ const processURL = (url, opts) => {
const tests = [
{
url: 'dns:domain.org',
uri: 'dns:domain.org',
shouldMatch: true
},
{
url: 'dns:domain.org?type=TXT',
uri: 'dns:domain.org?type=TXT',
shouldMatch: true
},
{
url: 'https://domain.org',
uri: 'https://domain.org',
shouldMatch: false
}
]
exports.reURL = reURL
exports.reURI = reURI
exports.processURL = processURL
exports.tests = tests

View file

@ -1,16 +1,16 @@
const reURL = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
const reURI = /^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
const processURL = (url, opts) => {
const match = url.match(reURL)
const processURL = (uri, opts) => {
const match = uri.match(reURI)
return {
type: "xmpp",
profile: {
display: `${match[1]}@${match[2]}`,
url: url
uri: uri
},
proof: {
url: `https://${opts.XMPP_VCARD_SERVER_DOMAIN}/api/vcard/${output.display}/DESC`,
uri: `https://${opts.XMPP_VCARD_SERVER_DOMAIN}/api/vcard/${output.display}/DESC`,
fetch: null
},
qr: null
@ -19,19 +19,19 @@ const processURL = (url, opts) => {
const tests = [
{
url: 'xmpp:alice@domain.org',
uri: 'xmpp:alice@domain.org',
shouldMatch: true
},
{
url: 'xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9',
uri: 'xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9',
shouldMatch: true
},
{
url: 'https://domain.org',
uri: 'https://domain.org',
shouldMatch: false
}
]
exports.reURL = reURL
exports.reURI = reURI
exports.processURL = processURL
exports.tests = tests