From 3d643afdfa49fd7252793f7648024090f205f11a Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Wed, 8 Mar 2023 13:46:41 +0100 Subject: [PATCH] fix: Fix Matrix URI format As per https://spec.matrix.org/latest/appendices/#matrix-uri-scheme, Matrix URIs should not contain any sigils. --- src/claimDefinitions/matrix.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/claimDefinitions/matrix.js b/src/claimDefinitions/matrix.js index a15f1ed..54806af 100644 --- a/src/claimDefinitions/matrix.js +++ b/src/claimDefinitions/matrix.js @@ -26,13 +26,15 @@ const processURI = (uri) => { } 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)) { return null } 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 { serviceprovider: { @@ -55,8 +57,8 @@ const processURI = (uri) => { access: E.ProofAccess.GRANTED, format: E.ProofFormat.JSON, data: { - eventId: params['org.keyoxide.e'], - roomId: params['org.keyoxide.r'] + eventId: paramEventId, + roomId: paramRoomId } } }, @@ -71,7 +73,7 @@ const processURI = (uri) => { const tests = [ { 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 }, {