chore: fix preview of files with non-latin names (closes #1056)

This commit is contained in:
Oleg Lobanov 2020-08-05 10:40:03 +02:00
parent a2fb499a20
commit 5881bc9ab0
No known key found for this signature in database
GPG Key ID: 7CC64E41212621B0
2 changed files with 9 additions and 4 deletions

View File

@ -99,13 +99,13 @@ export default {
return (this.nextLink !== '')
},
download () {
return `${baseURL}/api/raw${escape(this.req.path)}?auth=${this.jwt}`
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
},
previewUrl () {
if (this.req.type === 'image') {
return `${baseURL}/api/preview/big${escape(this.req.path)}?auth=${this.jwt}`
return `${baseURL}/api/preview/big${url.encodePath(this.req.path)}?auth=${this.jwt}`
}
return `${baseURL}/api/raw${escape(this.req.path)}?auth=${this.jwt}`
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
},
raw () {
return `${this.previewUrl}&inline=true`

View File

@ -20,7 +20,12 @@ function encodeRFC5987ValueChars(str) {
replace(/%(?:7C|60|5E)/g, unescape);
}
function encodePath(str) {
return str.split('/').map(v => encodeURIComponent(v)).join('/')
}
export default {
encodeRFC5987ValueChars: encodeRFC5987ValueChars,
removeLastDir: removeLastDir
removeLastDir: removeLastDir,
encodePath: encodePath
}