diff options
author | Michal Junek <michal@junek.pw> | 2022-02-04 15:41:20 +0300 |
---|---|---|
committer | Michal Junek <michal@junek.pw> | 2022-02-07 16:49:22 +0300 |
commit | 76a1f000a4f9c1b621c292cf8fc36125ce613c0a (patch) | |
tree | f6276b00e300164dd39c941c628fb39b0363603a /src | |
parent | b8e9d8e2590133b2525dae6302a1978af5e2d327 (diff) |
[master] Render data URL images as-is
Signed-off-by: Michal Junek <michal@junek.pw>
Diffstat (limited to 'src')
-rw-r--r-- | src/nodes/ImageView.vue | 5 | ||||
-rw-r--r-- | src/tests/nodes/ImageView.spec.js | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/nodes/ImageView.vue b/src/nodes/ImageView.vue index 11117d2bc..f8bd2ad6c 100644 --- a/src/nodes/ImageView.vue +++ b/src/nodes/ImageView.vue @@ -170,7 +170,7 @@ export default { }) } } - if (this.isRemoteUrl || this.isPreviewUrl) { + if (this.isRemoteUrl || this.isPreviewUrl || this.isDataUrl) { return this.src } if (this.hasPreview && this.mime !== 'image/gif') { @@ -186,6 +186,9 @@ export default { return this.src.match(/^(\/index.php)?\/core\/preview/) || this.src.match(/^(\/index.php)?\/apps\/files_sharing\/publicpreview\//) }, + isDataUrl() { + return this.src.startsWith('data:') + }, basename() { return decodeURI(this.src.split('?')[0]) }, diff --git a/src/tests/nodes/ImageView.spec.js b/src/tests/nodes/ImageView.spec.js index db1ac3e00..89ec542b8 100644 --- a/src/tests/nodes/ImageView.spec.js +++ b/src/tests/nodes/ImageView.spec.js @@ -65,6 +65,12 @@ describe('Image View src attribute based on markdown', () => { .toBe('https://nextcloud/index.php/apps/files_sharing/publicpreview/CSYoWifBzrsMWeA?file=/deck11-calendar.png&x=1760&y=990&a=true') }) + test('data urls are used as is', () => { + const src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=' + const wrapper = factory({src}) + expect(wrapper.find('.image__main').attributes('src')).toBe(src) + }) + test('image served by the Text app API', () => { const wrapper = factory({src: 'text://image?imageFileName=1640709467-a%60a%60a.png'}) expect(wrapper.vm.isSupportedImage).toBe(true) |