matrix: URIs #112

Merged
cadence merged 8 commits from mschae/out-of-your-element:matrix-uris into main 2026-11-28 03:44:30 +00:00
Showing only changes of commit 919f3e2851 - Show all commits

replace switch with if/else, don't encode sigils

mini-bomba 2026-11-19 00:40:08 +01:00
No known key found for this signature in database
GPG key ID: 30F8B138B4794886

View file

@ -604,28 +604,20 @@ function convertMatrixUris(input) {
const id = segments.shift() const id = segments.shift()
let sigil let sigil
switch(type) { if (type === "r" || type === "room") {
case "r": sigil = "#"
case "room": } else if (type === "roomid") {
sigil = "#" sigil = "!"
break } else if (type === "e" || type === "event") {
case "roomid": sigil = "$"
sigil = "!" } else if (type === "u" || type === "user") {
break sigil = "@"
case "e": } else {
case "event": // unknown type! bail
sigil = "$" return match
break
case "u":
case "user":
sigil = "@"
break
default:
// unknown type! bail
return match
} }
resultSegments.push(`${encodeURIComponent(sigil)}${id}`) resultSegments.push(`${sigil}${id}`)
} }
// now splice the path back together, add the query, and we're done! // now splice the path back together, add the query, and we're done!