Skip to content

Commit

Permalink
Merge branch 'develop' into tadzik/improve-mediaproxy-error-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tadzik authored Sep 5, 2024
2 parents 680a765 + 69d531b commit b085941
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/media-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ export class MediaProxy {
}
// Cache from this point onwards.
// Extract the media from the event.
const url = this.matrixClient.mxcToHttp('mxc://' + metadata.mxc);
const mxcMatch = metadata.mxc.match(new RegExp('^([^/]+)/(.+)$'));
if (!mxcMatch) {
throw new ApiError('Invalid MXC URI', ErrCode.BadValue);
}
const [, serverName, mediaId] = mxcMatch;
const url = `${this.matrixClient.homeserverUrl}/_matrix/client/v1/media/download/${serverName}/${mediaId}`;
return new Promise<void>((resolve, reject) => {
get(url, {
headers: {
Expand Down

0 comments on commit b085941

Please sign in to comment.