mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
fix: Fix Matrix URI format
As per https://spec.matrix.org/latest/appendices/#matrix-uri-scheme, Matrix URIs should not contain any sigils.
This commit is contained in:
parent
e84f09be5d
commit
3d643afdfa
1 changed files with 6 additions and 4 deletions
|
@ -26,13 +26,15 @@ const processURI = (uri) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = queryString.parse(match[2])
|
const params = queryString.parse(match[2])
|
||||||
|
const paramRoomId = `${params['org.keyoxide.r'][0] !== '!' ? '!' : ''}${params['org.keyoxide.r']}`
|
||||||
|
const paramEventId = `${params['org.keyoxide.e'][0] !== '$' ? '$' : ''}${params['org.keyoxide.e']}`
|
||||||
|
|
||||||
if (!('org.keyoxide.e' in params && 'org.keyoxide.r' in params)) {
|
if (!('org.keyoxide.e' in params && 'org.keyoxide.r' in params)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileUrl = `https://matrix.to/#/@${match[1]}`
|
const profileUrl = `https://matrix.to/#/@${match[1]}`
|
||||||
const eventUrl = `https://matrix.to/#/${params['org.keyoxide.r']}/${params['org.keyoxide.e']}`
|
const eventUrl = `https://matrix.to/#/${paramRoomId}/${paramEventId}`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
serviceprovider: {
|
serviceprovider: {
|
||||||
|
@ -55,8 +57,8 @@ const processURI = (uri) => {
|
||||||
access: E.ProofAccess.GRANTED,
|
access: E.ProofAccess.GRANTED,
|
||||||
format: E.ProofFormat.JSON,
|
format: E.ProofFormat.JSON,
|
||||||
data: {
|
data: {
|
||||||
eventId: params['org.keyoxide.e'],
|
eventId: paramEventId,
|
||||||
roomId: params['org.keyoxide.r']
|
roomId: paramRoomId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -71,7 +73,7 @@ const processURI = (uri) => {
|
||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
uri:
|
uri:
|
||||||
'matrix:u/alice:matrix.domain.org?org.keyoxide.r=!123:domain.org&org.keyoxide.e=$123',
|
'matrix:u/alice:matrix.domain.org?org.keyoxide.r=123:domain.org&org.keyoxide.e=123',
|
||||||
shouldMatch: true
|
shouldMatch: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue