2020-10-23 14:35:53 -06:00
|
|
|
const reURL = /^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/
|
|
|
|
|
|
|
|
const processURL = (url, opts) => {
|
|
|
|
const match = url.match(reURL)
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: "domain",
|
|
|
|
profile: {
|
|
|
|
display: match[1],
|
|
|
|
url: `https://${match[1]}`
|
|
|
|
},
|
|
|
|
proof: {
|
|
|
|
url: `https://dns.shivering-isles.com/dns-query?name=${match[1]}&type=TXT`,
|
|
|
|
fetch: null
|
|
|
|
},
|
|
|
|
qr: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const tests = [
|
|
|
|
{
|
2020-10-23 17:06:46 -06:00
|
|
|
url: 'dns:domain.org',
|
|
|
|
shouldMatch: true
|
2020-10-23 14:35:53 -06:00
|
|
|
},
|
|
|
|
{
|
2020-10-23 17:06:46 -06:00
|
|
|
url: 'dns:domain.org?type=TXT',
|
|
|
|
shouldMatch: true
|
2020-10-23 14:35:53 -06:00
|
|
|
},
|
|
|
|
{
|
2020-10-23 17:06:46 -06:00
|
|
|
url: 'https://domain.org',
|
2020-10-23 14:35:53 -06:00
|
|
|
shouldMatch: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
exports.reURL = reURL
|
|
|
|
exports.processURL = processURL
|
|
|
|
exports.tests = tests
|