Skip to content

Commit e6b18c4

Browse files
prantlfphated
andauthored
feat!: Support URI encoded source maps (#75)
fix!: No longer allow colon between charset and encoding feat!: Add capture groups to the commentRegex Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
1 parent 2572a2f commit e6b18c4

4 files changed

Lines changed: 221 additions & 26 deletions

File tree

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ Returns source map converter from given object.
3333

3434
Returns source map converter from given json string.
3535

36+
### fromURI(uri)
37+
38+
Returns source map converter from given uri encoded json string.
39+
3640
### fromBase64(base64)
3741

3842
Returns source map converter from given base64 encoded json string.
3943

4044
### fromComment(comment)
4145

42-
Returns source map converter from given base64 encoded json string prefixed with `//# sourceMappingURL=...`.
46+
Returns source map converter from given base64 or uri encoded json string prefixed with `//# sourceMappingURL=...`.
4347

4448
### fromMapFileComment(comment, mapFileDir)
4549

@@ -50,11 +54,11 @@ generated file, i.e. the one containing the source map.
5054

5155
### fromSource(source)
5256

53-
Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found.
57+
Finds last sourcemap comment in file and returns source map converter or returns `null` if no source map comment was found.
5458

5559
### fromMapFileSource(source, mapFileDir)
5660

57-
Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was
61+
Finds last sourcemap comment in file and returns source map converter or returns `null` if no source map comment was
5862
found.
5963

6064
The sourcemap will be read from the map file found by parsing `# sourceMappingURL=file` comment. For more info see
@@ -70,6 +74,10 @@ Converts source map to json string. If `space` is given (optional), this will be
7074
[JSON.stringify](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify) when the
7175
JSON string is generated.
7276

77+
### toURI()
78+
79+
Converts source map to uri encoded json string.
80+
7381
### toBase64()
7482

7583
Converts source map to base64 encoded json string.
@@ -81,6 +89,8 @@ Converts source map to an inline comment that can be appended to the source-file
8189
By default, the comment is formatted like: `//# sourceMappingURL=...`, which you would
8290
normally see in a JS source file.
8391

92+
When `options.encoding == 'uri'`, the data will be uri encoded, otherwise they will be base64 encoded.
93+
8494
When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file.
8595

8696
### addProperty(key, value)
@@ -107,6 +117,8 @@ Returns `src` with all source map comments pointing to map files removed.
107117

108118
Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments.
109119

120+
Breaks down a source map comment into groups: Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
121+
110122
### mapFileCommentRegex
111123

112124
Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments pointing to map files.

index.js

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ var path = require('path');
44

55
Object.defineProperty(exports, 'commentRegex', {
66
get: function getCommentRegex () {
7-
return /^\s*?\/(?:\/|\*?)[@#]\s+?sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*?)$/mg;
7+
// Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
8+
return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
89
}
910
});
1011

12+
1113
Object.defineProperty(exports, 'mapFileCommentRegex', {
1214
get: function getMapFileCommentRegex () {
1315
// Matches sourceMappingURL in either // or /* comment styles.
@@ -64,10 +66,23 @@ function readFromFileMap(sm, dir) {
6466
function Converter (sm, opts) {
6567
opts = opts || {};
6668

67-
if (opts.isFileComment) sm = readFromFileMap(sm, opts.commentFileDir);
68-
if (opts.hasComment) sm = stripComment(sm);
69-
if (opts.isEncoded) sm = decodeBase64(sm);
70-
if (opts.isJSON || opts.isEncoded) sm = JSON.parse(sm);
69+
if (opts.isFileComment) {
70+
sm = readFromFileMap(sm, opts.commentFileDir);
71+
}
72+
73+
if (opts.hasComment) {
74+
sm = stripComment(sm);
75+
}
76+
77+
if (opts.encoding === 'base64') {
78+
sm = decodeBase64(sm);
79+
} else if (opts.encoding === 'uri') {
80+
sm = decodeURIComponent(sm);
81+
}
82+
83+
if (opts.isJSON || opts.encoding) {
84+
sm = JSON.parse(sm);
85+
}
7186

7287
this.sourcemap = sm;
7388
}
@@ -104,10 +119,22 @@ function encodeBase64WithBtoa() {
104119
return btoa(unescape(encodeURIComponent(json)));
105120
}
106121

122+
Converter.prototype.toURI = function () {
123+
var json = this.toJSON();
124+
return encodeURIComponent(json);
125+
};
126+
107127
Converter.prototype.toComment = function (options) {
108-
var base64 = this.toBase64();
109-
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
110-
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
128+
var encoding, content, data;
129+
if (options != null && options.encoding === 'uri') {
130+
encoding = '';
131+
content = this.toURI();
132+
} else {
133+
encoding = ';base64';
134+
content = this.toBase64();
135+
}
136+
data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
137+
return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
111138
};
112139

113140
// returns copy instead of original
@@ -137,16 +164,22 @@ exports.fromJSON = function (json) {
137164
return new Converter(json, { isJSON: true });
138165
};
139166

167+
exports.fromURI = function (uri) {
168+
return new Converter(uri, { encoding: 'uri' });
169+
};
170+
140171
exports.fromBase64 = function (base64) {
141-
return new Converter(base64, { isEncoded: true });
172+
return new Converter(base64, { encoding: 'base64' });
142173
};
143174

144175
exports.fromComment = function (comment) {
176+
var m, encoding;
145177
comment = comment
146178
.replace(/^\/\*/g, '//')
147179
.replace(/\*\/$/g, '');
148-
149-
return new Converter(comment, { isEncoded: true, hasComment: true });
180+
m = exports.commentRegex.exec(comment);
181+
encoding = m && m[4] || 'uri';
182+
return new Converter(comment, { encoding: encoding, hasComment: true });
150183
};
151184

152185
exports.fromMapFileComment = function (comment, dir) {

test/comment-regex.js

Lines changed: 144 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,29 @@ function comment(prefix, suffix) {
1010
return rx.test(prefix + 'sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
1111
}
1212

13-
function commentWithCharSet(prefix, suffix, sep) {
14-
sep = sep || ':';
13+
function commentWithCharSet(prefix, suffix) {
1514
var rx = convert.commentRegex;
16-
return rx.test(prefix + 'sourceMappingURL=data:application/json;charset' + sep +'utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
15+
return rx.test(prefix + 'sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
16+
}
17+
18+
function commentURI(prefix, suffix) {
19+
var rx = convert.commentRegex;
20+
return rx.test(prefix + 'sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22file%22%3A%22%22%2C%22sources%22%3A%5B%22function%20foo()%20%7B%0A%20console.log(%22hello%20I%20am%20foo%22)%3B%0A%20console.log(%22who%20are%20you%22)%3B%0A%7D%0A%0Afoo()%3B%0A%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%22%7D' + suffix)
21+
}
22+
23+
function commentURIWithCharSet(prefix, suffix) {
24+
var rx = convert.commentRegex;
25+
return rx.test(prefix + 'sourceMappingURL=data:application/json;charset=utf-8,%7B%22version%22%3A3%2C%22file%22%3A%22%22%2C%22sources%22%3A%5B%22function%20foo()%20%7B%0A%20console.log(%22hello%20I%20am%20foo%22)%3B%0A%20console.log(%22who%20are%20you%22)%3B%0A%7D%0A%0Afoo()%3B%0A%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%22%7D' + suffix)
26+
}
27+
28+
function commentWithoutMediaType(prefix, suffix) {
29+
var rx = convert.commentRegex;
30+
return rx.test(prefix + 'sourceMappingURL=data:;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
31+
}
32+
33+
function commentURIWithoutMediaType(prefix, suffix) {
34+
var rx = convert.commentRegex;
35+
return rx.test(prefix + 'sourceMappingURL=data:,%7B%22version%22%3A3%2C%22file%22%3A%22%22%2C%22sources%22%3A%5B%22function%20foo()%20%7B%0A%20console.log(%22hello%20I%20am%20foo%22)%3B%0A%20console.log(%22who%20are%20you%22)%3B%0A%7D%0A%0Afoo()%3B%0A%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%22%7D' + suffix)
1736
}
1837

1938
// Source Map v2 Tests
@@ -28,15 +47,21 @@ test('comment regex old spec - @', function (t) {
2847
'\t/*@ ', // multi line style with leading tab
2948
'/*@ ', // multi line style with leading text
3049
].forEach(function (x) {
31-
t.ok(comment(x, ''), 'matches ' + x)
32-
t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset')
33-
t.ok(commentWithCharSet(x, '', '='), 'matches ' + x + ' with charset')
50+
t.ok(comment(x, ''), 'matches ' + x)
51+
t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset')
52+
t.ok(commentURI(x, ''), 'matches ' + x + ' uri')
53+
t.ok(commentURIWithCharSet(x, ''), 'matches ' + x + ' uri with charset')
54+
t.ok(commentWithoutMediaType(x, ''), 'matches ' + x + ' without media type')
55+
t.ok(commentURIWithoutMediaType(x, ''), 'matches ' + x + ' uri without media type')
3456
});
3557

3658
[
3759
' @// @',
3860
' @/* @',
39-
].forEach(function (x) { t.ok(!comment(x, ''), 'should not match ' + x) })
61+
].forEach(function (x) {
62+
t.ok(!comment(x, ''), 'should not match ' + x)
63+
t.ok(!commentURI(x, ''), 'should not match ' + x + ' uri')
64+
})
4065

4166
t.end()
4267
})
@@ -51,15 +76,123 @@ test('comment regex new spec - #', function (t) {
5176
'\t/*# ', // multi line style with leading tab
5277
'/*# ', // multi line style with leading text
5378
].forEach(function (x) {
54-
t.ok(comment(x, ''), 'matches ' + x)
55-
t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset')
56-
t.ok(commentWithCharSet(x, '', '='), 'matches ' + x + ' with charset')
79+
t.ok(comment(x, ''), 'matches ' + x)
80+
t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset')
81+
t.ok(commentURI(x, ''), 'matches ' + x + ' uri')
82+
t.ok(commentURIWithCharSet(x, ''), 'matches ' + x + ' uri with charset')
83+
t.ok(commentWithoutMediaType(x, ''), 'matches ' + x + ' without media type')
84+
t.ok(commentURIWithoutMediaType(x, ''), 'matches ' + x + ' uri without media type')
5785
});
5886

5987
[
6088
' #// #',
6189
' #/* #',
62-
].forEach(function (x) { t.ok(!comment(x, ''), 'should not match ' + x) })
90+
].forEach(function (x) {
91+
t.ok(!comment(x, ''), 'should not match ' + x)
92+
t.ok(!commentURI(x, ''), 'should not match ' + x + ' uri')
93+
})
94+
95+
t.end()
96+
})
97+
98+
test('comment regex groups', function (t) {
99+
function comment(prefix, suffix) {
100+
var rx = convert.commentRegex;
101+
return rx.exec(prefix + 'sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
102+
}
103+
104+
function commentURI(prefix, suffix) {
105+
var rx = convert.commentRegex;
106+
return rx.exec(prefix + 'sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22file%22%3A%22%22%2C%22sources%22%3A%5B%22function%20foo()%20%7B%0A%20console.log(%22hello%20I%20am%20foo%22)%3B%0A%20console.log(%22who%20are%20you%22)%3B%0A%7D%0A%0Afoo()%3B%0A%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%22%7D' + suffix)
107+
}
108+
109+
function commentWithCharSet(prefix, suffix) {
110+
var rx = convert.commentRegex;
111+
return rx.exec(prefix + 'sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
112+
}
113+
114+
function commentURIWithCharSet(prefix, suffix) {
115+
var rx = convert.commentRegex;
116+
return rx.exec(prefix + 'sourceMappingURL=data:application/json;charset=utf-8,%7B%22version%22%3A3%2C%22file%22%3A%22%22%2C%22sources%22%3A%5B%22function%20foo()%20%7B%0A%20console.log(%22hello%20I%20am%20foo%22)%3B%0A%20console.log(%22who%20are%20you%22)%3B%0A%7D%0A%0Afoo()%3B%0A%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%22%7D' + suffix)
117+
}
118+
119+
function commentWithoutMediaType(prefix, suffix) {
120+
var rx = convert.commentRegex;
121+
return rx.exec(prefix + 'sourceMappingURL=data:;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix)
122+
}
123+
124+
function commentURIWithoutMediaType(prefix, suffix) {
125+
var rx = convert.commentRegex;
126+
return rx.exec(prefix + 'sourceMappingURL=data:,%7B%22version%22%3A3%2C%22file%22%3A%22%22%2C%22sources%22%3A%5B%22function%20foo()%20%7B%0A%20console.log(%22hello%20I%20am%20foo%22)%3B%0A%20console.log(%22who%20are%20you%22)%3B%0A%7D%0A%0Afoo()%3B%0A%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAA%22%7D' + suffix)
127+
}
128+
129+
[
130+
' //# ', // with leading spaces
131+
'\t//# ', // with leading tab
132+
'//# ', // with leading text
133+
'/*# ', // multi line style
134+
' /*# ', // multi line style with leading spaces
135+
'\t/*# ', // multi line style with leading tab
136+
'/*# ', // multi line style with leading text
137+
].forEach(function (x) {
138+
var m;
139+
m = comment(x, '')
140+
t.ok(m, 'matches ' + x)
141+
t.ok(m[0], 'comment')
142+
t.equal(m[1], 'application/json', 'media type')
143+
t.equal(m[2], 'application/json', 'MIME type')
144+
t.equal(m[3], undefined, 'undefined charset')
145+
t.equal(m[4], 'base64', 'base64 encoding')
146+
t.ok(m[5], 'data')
147+
m = commentURI(x, '')
148+
t.ok(m, 'matches ' + x + ' uri')
149+
t.ok(m[0], 'comment uri')
150+
t.equal(m[1], 'application/json', 'media type uri')
151+
t.equal(m[2], 'application/json', 'MIME type uri')
152+
t.equal(m[3], undefined, 'undefined charset uri')
153+
t.equal(m[4], undefined, 'undefined encoding uri')
154+
t.ok(m[5], 'data uri')
155+
m = commentWithCharSet(x, '')
156+
t.ok(m, 'matches ' + x + ' with charset')
157+
t.ok(m[0], 'comment with charset')
158+
t.equal(m[1], 'application/json;charset=utf-8', 'media type with charset')
159+
t.equal(m[2], 'application/json', 'MIME type with charset')
160+
t.equal(m[3], 'utf-8', 'charset with utf-8')
161+
t.equal(m[4], 'base64', 'base64 encoding with charset')
162+
t.ok(m[5], 'data with charset')
163+
m = commentURIWithCharSet(x, '')
164+
t.ok(m, 'matches ' + x + ' uri with charset')
165+
t.ok(m[0], 'comment uri with charset')
166+
t.equal(m[1], 'application/json;charset=utf-8', 'media type uri with charset')
167+
t.equal(m[2], 'application/json', 'MIME type uri with charset')
168+
t.equal(m[3], 'utf-8', 'charset uri with utf-8')
169+
t.equal(m[4], undefined, 'undefined encoding uri with charset')
170+
t.ok(m[5], 'data with charset')
171+
m = commentWithoutMediaType(x, '')
172+
t.ok(m, 'matches ' + x + ' without media type')
173+
t.ok(m[0], 'comment without media type')
174+
t.equal(m[1], undefined, 'undefined media type')
175+
t.equal(m[2], undefined, 'undefined MIME type')
176+
t.equal(m[3], undefined, 'undefined charset without media type')
177+
t.equal(m[4], 'base64', 'base64 encoding without media type')
178+
t.ok(m[5], 'data without media type')
179+
m = commentURIWithoutMediaType(x, '')
180+
t.ok(m, 'matches ' + x + ' uri without media type')
181+
t.ok(m[0], 'comment uri without media type')
182+
t.equal(m[1], undefined, 'undefined media type')
183+
t.equal(m[2], undefined, 'undefined MIME type')
184+
t.equal(m[3], undefined, 'undefined charset uri without media type')
185+
t.equal(m[4], undefined, 'undefined encoding uri without media type')
186+
t.ok(m[5], 'data uri without media type')
187+
});
188+
189+
[
190+
' #// #',
191+
' #/* #',
192+
].forEach(function (x) {
193+
t.ok(!comment(x, ''), 'should not match ' + x)
194+
t.ok(!commentURI(x, ''), 'should not match ' + x + ' uri')
195+
})
63196

64197
t.end()
65198
})

test/convert-source-map.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,46 @@ var test = require('tap').test
55
, generator = require('inline-source-map')
66
, convert = require('..')
77

8+
function decodeBase64WithBufferFrom(base64) {
9+
return Buffer.from(base64, 'base64').toString();
10+
}
11+
12+
function decodeBase64WithNewBuffer(base64) {
13+
return new Buffer(base64, 'base64').toString();
14+
}
15+
816
var gen = generator({charset:"utf-8"})
917
.addMappings('foo.js', [{ original: { line: 2, column: 3 } , generated: { line: 5, column: 10 } }], { line: 5 })
1018
.addGeneratedMappings('bar.js', 'var a = 2;\nconsole.log(a)', { line: 23, column: 22 })
1119

1220
, base64 = gen.base64Encode()
21+
, decodeBase64 = typeof Buffer.from ? decodeBase64WithBufferFrom : decodeBase64WithNewBuffer
22+
, uri = encodeURIComponent(decodeBase64(base64))
1323
, comment = gen.inlineMappingUrl()
24+
, comment2 = '//# sourceMappingURL=data:application/json;charset=utf-8,' + uri
1425
, json = gen.toString()
1526
, obj = JSON.parse(json)
1627

1728
test('different formats', function (t) {
1829

19-
t.equal(convert.fromComment(comment).toComment(), comment, 'comment -> comment')
30+
t.equal(convert.fromComment(comment).toComment(), comment, 'comment -> comment (base64)')
31+
t.equal(convert.fromComment(comment2).toComment({ encoding: 'uri' }), comment2, 'comment -> comment (uri)')
2032
t.equal(convert.fromComment(comment).toBase64(), base64, 'comment -> base64')
33+
t.equal(convert.fromComment(comment).toURI(), uri, 'comment -> uri')
2134
t.equal(convert.fromComment(comment).toJSON(), json, 'comment -> json')
2235
t.deepEqual(convert.fromComment(comment).toObject(), obj, 'comment -> object')
2336

2437
t.equal(convert.fromBase64(base64).toBase64(), base64, 'base64 -> base64')
38+
t.equal(convert.fromURI(uri).toURI(), uri, 'uri -> uri')
2539
t.equal(convert.fromBase64(base64).toComment(), comment, 'base64 -> comment')
2640
t.equal(convert.fromBase64(base64).toJSON(), json, 'base64 -> json')
41+
t.equal(convert.fromURI(uri).toJSON(), json, 'uri -> json')
2742
t.deepEqual(convert.fromBase64(base64).toObject(), obj, 'base64 -> object')
43+
t.deepEqual(convert.fromURI(uri).toObject(), obj, 'uri -> object')
2844

2945
t.equal(convert.fromJSON(json).toJSON(), json, 'json -> json')
3046
t.equal(convert.fromJSON(json).toBase64(), base64, 'json -> base64')
47+
t.equal(convert.fromJSON(json).toURI(), uri, 'json -> uri')
3148
t.equal(convert.fromJSON(json).toComment(), comment, 'json -> comment')
3249
t.deepEqual(convert.fromJSON(json).toObject(), obj, 'json -> object')
3350
t.end()

0 commit comments

Comments
 (0)