Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix images in public links
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Sep 25, 2020
commit 4077cdc43aafe4e7a2e6c85a6306c6f26e5a3487
5 changes: 4 additions & 1 deletion src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export default {
},
computed: {
imageUrl() {
if (this.src.startsWith('http://') || this.src.startsWith('https://')) {
return this.src
}
if (this.hasPreviewUrl) {
return this.src
}
Expand All @@ -114,7 +117,7 @@ export default {
return getQueryVariable(this.src, 'fileId')
},
hasPreviewUrl() {
return this.src.match(/^(\/index.php)?\/core\/preview/)
return this.src.match(/^(\/index.php)?\/core\/preview/) || this.src.match(/^(\/index.php)?\/apps\/files_sharing\/publicpreview\//)
},
mimeIcon() {
const mime = getQueryVariable(this.src, 'mimetype')
Expand Down
7 changes: 7 additions & 0 deletions src/tests/nodes/ImageView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ describe('Image View src attribute based on markdown', () => {
expect(wrapper.find('.image__main').attributes('src'))
.toBe('/core/preview.png?file=%2Fcurrent%2Fsub%2Fasdf.jpg&x=1024&y=1024&a=true')
})

test('public share link previews are just used as they are', () => {
const wrapper = factory({src: 'https://nextcloud/index.php/apps/files_sharing/publicpreview/CSYoWifBzrsMWeA?file=/deck11-calendar.png&x=1760&y=990&a=true'})
expect(wrapper.vm.isSupportedImage).toBe(true)
expect(wrapper.find('.image__main').attributes('src'))
.toBe('https://nextcloud/index.php/apps/files_sharing/publicpreview/CSYoWifBzrsMWeA?file=/deck11-calendar.png&x=1760&y=990&a=true')
})
})