From c3adebea06f3d5cb80226ec456e8dbf30586e0a0 Mon Sep 17 00:00:00 2001 From: Stefan Lau Date: Tue, 11 Dec 2018 16:52:11 +0100 Subject: [PATCH] fix(backend-gitlab): show svg previews (#1946) --- packages/netlify-cms-backend-gitlab/src/implementation.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/netlify-cms-backend-gitlab/src/implementation.js b/packages/netlify-cms-backend-gitlab/src/implementation.js index 74019f47..0a83eb79 100644 --- a/packages/netlify-cms-backend-gitlab/src/implementation.js +++ b/packages/netlify-cms-backend-gitlab/src/implementation.js @@ -152,6 +152,13 @@ export default class GitLab { sem.take(() => this.api .readFile(path, id, { parseText: false }) + .then(blob => { + // svgs are returned with mimetype "text/plain" by gitlab + if (blob.type === 'text/plain' && name.match(/\.svg$/i)) { + return new window.Blob([blob], { type: 'image/svg+xml' }); + } + return blob; + }) .then(resolve, reject) .finally(() => sem.leave()), ),