Replace hard coded forExport string by mxc url

This commit is contained in:
Jaiwanth 2021-06-29 11:29:05 +05:30
parent e404fa3cae
commit 6cbbc0ecb4
5 changed files with 8 additions and 5 deletions

View file

@ -42,7 +42,7 @@ export default class MAudioBody extends React.Component {
}
_getContentUrl() {
if (this.props.forExport) return "forExport";
if (this.props.forExport) return this.props.mxEvent.getContent().url;
const media = mediaFromContent(this.props.mxEvent.getContent());
if (media.isEncrypted) {
return this.state.decryptedUrl;

View file

@ -172,7 +172,7 @@ export default class MImageBody extends React.Component {
}
_getContentUrl() {
if (this.props.forExport) return "forExport";
if (this.props.forExport) return this.props.mxEvent.getContent().url;
const media = mediaFromContent(this.props.mxEvent.getContent());
if (media.isEncrypted) {
return this.state.decryptedUrl;

View file

@ -78,7 +78,7 @@ export default class MVideoBody extends React.PureComponent<IProps, IState> {
}
private getContentUrl(): string|null {
if (this.props.forExport) return "forExport";
if (this.props.forExport) return this.props.mxEvent.getContent().url;
const media = mediaFromContent(this.props.mxEvent.getContent());
if (media.isEncrypted) {
return this.state.decryptedUrl;

View file

@ -263,7 +263,9 @@ export default class HTMLExporter extends Exporter {
</MatrixClientContext.Provider>
</div>
let eventTileMarkup = renderToStaticMarkup(eventTile);
if (filePath) eventTileMarkup = eventTileMarkup.replace(/(src=|href=)"forExport"/g, `$1"${filePath}"`);
if (filePath) {
eventTileMarkup = eventTileMarkup.split(mxEv.getContent().url).join(filePath);
}
if (hasAvatar) {
eventTileMarkup = eventTileMarkup.replace(
encodeURI(this.getAvatarURL(mxEv)).replace(/&/g, '&amp;'),

View file

@ -136,7 +136,8 @@ export default function streamToZIP(underlyingSource: UnderlyingSource) {
const date = new Date(typeof fileLike.lastModified === 'undefined' ? Date.now() : fileLike.lastModified);
if (fileLike.directory && !name.endsWith('/')) name += '/';
if (files[name]) throw new Error('File already exists.');
// if file already exists, do not enqueue
if (files[name]) return;
const nameBuf = encoder.encode(name);
filenames.push(name);