-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathuri.js
More file actions
37 lines (32 loc) · 672 Bytes
/
uri.js
File metadata and controls
37 lines (32 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* imacss
*
* Copyright(c) 2014 - 2015 André König <andre.koenig@posteo.de>
* MIT Licensed
*
*/
/**
* @author André König <andre.koenig@posteo.de>
*
*/
'use strict';
/**
* Constructs a RFC 2397 conform data URI.
*
* @param {object} image The vinyl file object
*
* @return {string} The created data URI
*
*/
module.exports.constructDataURI = function constructDataURI (image) {
var data = image.base64;
var type = 'base64';
if ('image/svg+xml' === image.mime) {
type = 'utf-8';
data = image.contents
.toString(type)
.replace(/\r?\n|\r/g, '')
.replace('#', '%23');
}
return 'data:' + image.mime + ';' + type + ',' + data;
};