fixes files with hash in name

This commit is contained in:
Weidi Deng 2020-12-13 10:23:44 +08:00
parent 55c19c20dd
commit 621093e87d

View File

@ -116,6 +116,9 @@ export default {
absoluteParts.shift() absoluteParts.shift()
absoluteParts.forEach((_, i) => absoluteParts[i] = encodeURIComponent(absoluteParts[i]))
urlParts.forEach((_, i) => urlParts[i] = encodeURIComponent(urlParts[i]))
if (absoluteParts[absoluteParts.length - 1] === '') absoluteParts.pop() if (absoluteParts[absoluteParts.length - 1] === '') absoluteParts.pop()
if (urlParts[urlParts.length - 1] === '') urlParts.pop() if (urlParts[urlParts.length - 1] === '') urlParts.pop()
@ -129,10 +132,10 @@ export default {
}, },
link: function () { link: function () {
if (!this.hasSelected) return `${baseURL}/api/public/dl/${this.hash}/${this.path}` if (!this.hasSelected) return `${baseURL}/api/public/dl/${this.hash}/${this.path}`
if (this.selected.length === 1) return `${baseURL}/api/public/dl/${this.hash}/${this.path}/${encodeURI(this.selected[0])}` if (this.selected.length === 1) return `${baseURL}/api/public/dl/${this.hash}/${this.path}/${encodeURIComponent(this.selected[0])}`
let files = [] let files = []
for (let s of this.selected) { for (let s of this.selected) {
files.push(encodeURI(s)) files.push(encodeURIComponent(s))
} }
return `${baseURL}/api/public/dl/${this.hash}/${this.path}/?files=${encodeURIComponent(files.join(','))}` return `${baseURL}/api/public/dl/${this.hash}/${this.path}/?files=${encodeURIComponent(files.join(','))}`
}, },
@ -195,7 +198,7 @@ export default {
this.selected = [] this.selected = []
this.firstSelected = -1 this.firstSelected = -1
try { try {
this.file = await api.getHash(this.$route.params.pathMatch) this.file = await api.getHash(encodeURIComponent(this.$route.params.pathMatch))
this.loaded = true this.loaded = true
} catch (e) { } catch (e) {
this.notFound = true this.notFound = true
@ -253,7 +256,7 @@ export default {
this.addSelected(name) this.addSelected(name)
}, },
dblclick: function (name) { dblclick: function (name) {
this.$router.push({path: `/share/${this.hash}/${this.path}/${name}`}) this.$router.push({path: `/share/${this.hash}/${this.path}/${encodeURIComponent(name)}`})
}, },
touchstart (name) { touchstart (name) {
setTimeout(() => { setTimeout(() => {