provide more details about MXC URL when parsing fails
This commit is contained in:
parent
ae50f2ee5d
commit
ddf835c4d1
@ -2,7 +2,7 @@ export const getServerAndMediaIdFromMxcUrl = (mxcUrl: string): { serverName: str
|
|||||||
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");
|
return { serverName: "", mediaId: "" };
|
||||||
}
|
}
|
||||||
const serverName = ret[1];
|
const serverName = ret[1];
|
||||||
const mediaId = ret[2];
|
const mediaId = ret[2];
|
||||||
@ -17,6 +17,7 @@ export const fetchAuthenticatedMedia = async (mxcUrl: string, type: MediaType):
|
|||||||
|
|
||||||
const { serverName, mediaId } = getServerAndMediaIdFromMxcUrl(mxcUrl);
|
const { serverName, mediaId } = getServerAndMediaIdFromMxcUrl(mxcUrl);
|
||||||
if (!serverName || !mediaId) {
|
if (!serverName || !mediaId) {
|
||||||
|
console.error("Invalid mxcUrl", mxcUrl, "serverName:", serverName, "mediaId:", mediaId);
|
||||||
throw new Error("Invalid mxcUrl");
|
throw new Error("Invalid mxcUrl");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user