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()
let sigil
switch(type) {
case "r":
case "room":
sigil = "#"
break
case "roomid":
sigil = "!"
break
case "e":
case "event":
sigil = "$"
break
case "u":
case "user":
sigil = "@"
break
default:
// unknown type! bail
return match
if (type === "r" || type === "room") {
sigil = "#"
} else if (type === "roomid") {
sigil = "!"
} else if (type === "e" || type === "event") {
sigil = "$"
} else if (type === "u" || type === "user") {
sigil = "@"
} else {
// 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!