fix: encodeURI for thumbnails and timelapse files (#539)
GET requests including file names with special characters such as '%' will properly encode the request to the server.
This commit is contained in:
parent
bf60aef344
commit
7b19c902de
@ -924,7 +924,9 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
|
|||||||
thumb.height >= thumbnailSmallMin && thumb.height <= thumbnailSmallMax
|
thumb.height >= thumbnailSmallMin && thumb.height <= thumbnailSmallMax
|
||||||
)
|
)
|
||||||
|
|
||||||
if (thumbnail && 'relative_path' in thumbnail) return this.apiUrl+'/server/files/'+this.currentPath+'/'+encodeURI(thumbnail.relative_path)+'?timestamp='+item.modified.getTime()
|
if (thumbnail && 'relative_path' in thumbnail) {
|
||||||
|
return encodeURI(`${this.apiUrl}/server/files/${this.currentPath}/${thumbnail.relative_path}?timestamp=${item.modified.getTime()}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
@ -934,7 +936,9 @@ export default class GcodefilesPanel extends Mixins(BaseMixin) {
|
|||||||
if (item.thumbnails?.length) {
|
if (item.thumbnails?.length) {
|
||||||
const thumbnail = item.thumbnails.find(thumb => thumb.width >= thumbnailBigMin)
|
const thumbnail = item.thumbnails.find(thumb => thumb.width >= thumbnailBigMin)
|
||||||
|
|
||||||
if (thumbnail && 'relative_path' in thumbnail) return this.apiUrl+'/server/files/'+this.currentPath+'/'+encodeURI(thumbnail.relative_path)+'?timestamp='+item.modified.getTime()
|
if (thumbnail && 'relative_path' in thumbnail) {
|
||||||
|
return encodeURI(`${this.apiUrl}/server/files/${this.currentPath}/${thumbnail.relative_path}?timestamp=${item.modified.getTime()}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
@ -595,8 +595,9 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
|
|||||||
relative_url = item.filename.substr(0, item.filename.lastIndexOf('/')+1)
|
relative_url = item.filename.substr(0, item.filename.lastIndexOf('/')+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thumbnail && 'relative_path' in thumbnail)
|
if (thumbnail && 'relative_path' in thumbnail) {
|
||||||
return this.apiUrl+'/server/files/gcodes/'+relative_url+thumbnail.relative_path+'?timestamp='+item.metadata.modified
|
return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${item.metadata.modified}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -616,7 +617,7 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (thumbnail && 'relative_path' in thumbnail)
|
if (thumbnail && 'relative_path' in thumbnail)
|
||||||
return this.apiUrl+'/server/files/gcodes/'+relative_url+thumbnail.relative_path+'?timestamp='+item.metadata.modified
|
return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${item.metadata.modified}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
@ -657,7 +657,7 @@ export default class ConfigFilesPanel extends Mixins(BaseMixin) {
|
|||||||
|
|
||||||
downloadFile() {
|
downloadFile() {
|
||||||
const filename = (this.absolutePath+'/'+this.contextMenu.item.filename)
|
const filename = (this.absolutePath+'/'+this.contextMenu.item.filename)
|
||||||
const href = this.apiUrl + '/server/files' + filename
|
const href = encodeURI(`${this.apiUrl}/server/files${filename}`)
|
||||||
window.open(href)
|
window.open(href)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,8 +513,9 @@ export default class StatusPanel extends Mixins(BaseMixin) {
|
|||||||
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/')+1)
|
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/')+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thumbnail && 'relative_path' in thumbnail)
|
if (thumbnail && 'relative_path' in thumbnail) {
|
||||||
return this.apiUrl+'/server/files/gcodes/'+relative_url+thumbnail.relative_path+'?timestamp='+this.current_file.modified
|
return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${this.current_file.modified}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,8 +535,9 @@ export default class StatusPanel extends Mixins(BaseMixin) {
|
|||||||
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/')+1)
|
relative_url = this.current_file.filename.substr(0, this.current_file.filename.lastIndexOf('/')+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thumbnail && 'relative_path' in thumbnail)
|
if (thumbnail && 'relative_path' in thumbnail) {
|
||||||
return this.apiUrl+'/server/files/gcodes/'+relative_url+thumbnail.relative_path+'?timestamp='+this.current_file.modified
|
return encodeURI(`${this.apiUrl}/server/files/gcodes/${relative_url+thumbnail.relative_path}?timestamp=${this.current_file.modified}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ export default class TimelapseFilesPanel extends Mixins(BaseMixin) {
|
|||||||
const filename = item.filename.slice(0, item.filename.lastIndexOf('.'))
|
const filename = item.filename.slice(0, item.filename.lastIndexOf('.'))
|
||||||
const preview = this.files?.find((file) => file.filename === filename+'.jpg')
|
const preview = this.files?.find((file) => file.filename === filename+'.jpg')
|
||||||
if (preview) {
|
if (preview) {
|
||||||
return this.apiUrl+'/server/files/'+this.currentPath+'/'+preview.filename+'?timestamp='+preview.modified.getTime()
|
return encodeURI(`${this.apiUrl}/server/files/${this.currentPath}/${preview.filename}?timestamp=${preview.modified.getTime()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
@ -457,7 +457,7 @@ export default class TimelapseFilesPanel extends Mixins(BaseMixin) {
|
|||||||
else if (item.filename.endsWith('zip')) {
|
else if (item.filename.endsWith('zip')) {
|
||||||
this.downloadFile(item.filename)
|
this.downloadFile(item.filename)
|
||||||
} else if (item.filename.endsWith('mp4')) {
|
} else if (item.filename.endsWith('mp4')) {
|
||||||
this.videoDialogFilename = this.currentPath + '/' + item.filename
|
this.videoDialogFilename = encodeURI(`${this.currentPath}/${item.filename}`)
|
||||||
this.boolVideoDialog = true
|
this.boolVideoDialog = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user