fix(backend-gitlab): show svg previews (#1946)

This commit is contained in:
Stefan Lau 2018-12-11 16:52:11 +01:00 committed by Shawn Erquhart
parent 0f1ebd1060
commit c3adebea06

View File

@ -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()),
),