Relax mxc regexp

The spec doesn't say which characters are permitted in the opaque ID,
but in real life we at least need a hyphen. For lack of a better
reference, I copied gomuks.
This commit is contained in:
Cadence Ember
2026-07-03 22:35:10 +12:00
parent 47ccf986d8
commit cad815896b
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -474,7 +474,7 @@ async function ping() {
async function getMedia(mxc, init = {}) {
init = {...init}
const mediaParts = mxc?.match(/^mxc:\/\/([^/]+)\/(\w+)$/)
const mediaParts = mxc?.match(/^mxc:\/\/([^/]+)\/([a-zA-Z0-9_-]+)$/)
assert(mediaParts)
let route = "download"
+1 -1
View File
@@ -250,7 +250,7 @@ function getPublicUrlForMxc(mxc) {
*/
function makeMxcPublic(mxc) {
assert(hasher, "xxhash is not ready yet")
const mediaParts = mxc?.match(/^mxc:\/\/([^/]+)\/(\w+)$/)
const mediaParts = mxc?.match(/^mxc:\/\/([^/]+)\/([a-zA-Z0-9_-]+)$/)
if (!mediaParts) return undefined
const serverAndMediaID = `${mediaParts[1]}/${mediaParts[2]}`