forked from Mirrors/doipjs
Replace URL with URI
This commit is contained in:
parent
ed2178b652
commit
43b16ffbaf
2 changed files with 18 additions and 18 deletions
|
@ -1,16 +1,16 @@
|
||||||
const reURL = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
|
const reURI = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
|
||||||
|
|
||||||
const processURL = (url, opts) => {
|
const processURL = (uri, opts) => {
|
||||||
const match = url.match(reURL)
|
const match = uri.match(reURL)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "domain",
|
type: "domain",
|
||||||
profile: {
|
profile: {
|
||||||
display: match[1],
|
display: match[1],
|
||||||
url: `https://${match[1]}`
|
uri: `https://${match[1]}`
|
||||||
},
|
},
|
||||||
proof: {
|
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
|
fetch: null
|
||||||
},
|
},
|
||||||
qr: null
|
qr: null
|
||||||
|
@ -19,19 +19,19 @@ const processURL = (url, opts) => {
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
url: 'dns:domain.org',
|
uri: 'dns:domain.org',
|
||||||
shouldMatch: true
|
shouldMatch: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
url: 'dns:domain.org?type=TXT',
|
uri: 'dns:domain.org?type=TXT',
|
||||||
shouldMatch: true
|
shouldMatch: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
url: 'https://domain.org',
|
uri: 'https://domain.org',
|
||||||
shouldMatch: false
|
shouldMatch: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
exports.reURL = reURL
|
exports.reURI = reURI
|
||||||
exports.processURL = processURL
|
exports.processURL = processURL
|
||||||
exports.tests = tests
|
exports.tests = tests
|
||||||
|
|
|
@ -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 processURL = (uri, opts) => {
|
||||||
const match = url.match(reURL)
|
const match = uri.match(reURI)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "xmpp",
|
type: "xmpp",
|
||||||
profile: {
|
profile: {
|
||||||
display: `${match[1]}@${match[2]}`,
|
display: `${match[1]}@${match[2]}`,
|
||||||
url: url
|
uri: uri
|
||||||
},
|
},
|
||||||
proof: {
|
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
|
fetch: null
|
||||||
},
|
},
|
||||||
qr: null
|
qr: null
|
||||||
|
@ -19,19 +19,19 @@ const processURL = (url, opts) => {
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
url: 'xmpp:alice@domain.org',
|
uri: 'xmpp:alice@domain.org',
|
||||||
shouldMatch: true
|
shouldMatch: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
url: 'xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9',
|
uri: 'xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9',
|
||||||
shouldMatch: true
|
shouldMatch: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
url: 'https://domain.org',
|
uri: 'https://domain.org',
|
||||||
shouldMatch: false
|
shouldMatch: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
exports.reURL = reURL
|
exports.reURI = reURI
|
||||||
exports.processURL = processURL
|
exports.processURL = processURL
|
||||||
exports.tests = tests
|
exports.tests = tests
|
||||||
|
|
Loading…
Reference in a new issue