From e1e8fa410a7bfa7448213a27d206f8d081b95086 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Mon, 27 Aug 2018 18:14:29 +0100 Subject: [PATCH] escape special characters for the encoded path (#262) --- app/src/component/mediaPlayer/view.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/component/mediaPlayer/view.js b/app/src/component/mediaPlayer/view.js index b2db5e51..2caafc31 100644 --- a/app/src/component/mediaPlayer/view.js +++ b/app/src/component/mediaPlayer/view.js @@ -30,6 +30,7 @@ class MediaPlayer extends React.PureComponent { constructor(props) { super(props); this.state = { + encodedFilePath: null, rate: 1, volume: 1, muted: false, @@ -284,9 +285,15 @@ class MediaPlayer extends React.PureComponent { } getEncodedDownloadPath = (fileInfo) => { + if (this.state.encodedFilePath) { + return this.state.encodedFilePath; + } + const { file_name: fileName } = fileInfo; const encodedFileName = encodeURIComponent(fileName).replace(/!/g, '%21'); - return fileInfo.download_path.replace(new RegExp(fileName, 'g'), encodedFileName); + const encodedFilePath = fileInfo.download_path.replace(fileName, encodedFileName); + this.setState({ encodedFilePath }); + return encodedFilePath; } render() {