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:
Yarmo Mackenbach 2023-03-08 13:46:41 +01:00
parent e84f09be5d
commit 3d643afdfa
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -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
}, },
{ {