escape special characters for the encoded path (#262)

This commit is contained in:
Akinwale Ariwodola 2018-08-27 18:14:29 +01:00 committed by GitHub
parent becf21b7ea
commit e1e8fa410a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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() {