ensure MXC URLs properly parsed when media IDs contain hypens, fixes #494

This commit is contained in:
Aine
2025-04-15 11:17:12 +03:00
parent 61013e1875
commit 54b67b3b48

View File

@@ -1,5 +1,5 @@
export const getServerAndMediaIdFromMxcUrl = (mxcUrl: string): { serverName: string; mediaId: string } => { export const getServerAndMediaIdFromMxcUrl = (mxcUrl: string): { serverName: string; mediaId: string } => {
const re = /^mxc:\/\/([^/]+)\/(\w+)/; const re = /^mxc:\/\/([^/]+)\/([\w-]+)$/;
const ret = re.exec(mxcUrl); const ret = re.exec(mxcUrl);
if (ret == null) { if (ret == null) {
throw new Error("Invalid mxcUrl"); throw new Error("Invalid mxcUrl");