fix: optimize file URL encoding by consolidating replacement logic for backslashes and slashes
This commit is contained in:
parent
ed1bd0f1f5
commit
a6713bae95
@ -37,8 +37,7 @@ export default {
|
||||
previewUrl: function(username, file, token, shareToken, serverUrl) {
|
||||
let baseUrl = serverUrl || this.baseUrl
|
||||
let fileUrl = `${baseUrl}/file/${store.getters.name}${encodeURIComponent(file.path)}${encodeURIComponent(file.name)}`
|
||||
fileUrl = fileUrl.replaceAll(/%5C/g, '/')
|
||||
fileUrl = fileUrl.replaceAll(/%2F/g, '/')
|
||||
fileUrl = fileUrl.replaceAll(/%5C|%2F/g, '/')
|
||||
|
||||
if (file.userId !== store.getters.userId && token && !shareToken) {
|
||||
return `${baseUrl}/pre-file/${file.id}/${encodeURIComponent(file.name)}?jmal-token=${token}&name=${username}`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user