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