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:
+1
-1
@@ -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
@@ -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]}`
|
||||
|
||||
Reference in New Issue
Block a user