Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80724 views
1
var B = require('../').Buffer
2
var test = require('tape')
3
if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false
4
5
6
test('base64: ignore whitespace', function (t) {
7
var text = '\n YW9ldQ== '
8
var buf = new B(text, 'base64')
9
t.equal(buf.toString(), 'aoeu')
10
t.end()
11
})
12
13
test('base64: strings without padding', function (t) {
14
t.equal((new B('YW9ldQ', 'base64').toString()), 'aoeu')
15
t.end()
16
})
17
18
test('base64: newline in utf8 -- should not be an issue', function (t) {
19
t.equal(
20
new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK', 'base64').toString('utf8'),
21
'---\ntitle: Three dashes marks the spot\ntags:\n'
22
)
23
t.end()
24
})
25
26
test('base64: newline in base64 -- should get stripped', function (t) {
27
t.equal(
28
new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK\nICAtIHlhbWwKICAtIGZyb250LW1hdHRlcgogIC0gZGFzaGVzCmV4cGFuZWQt', 'base64').toString('utf8'),
29
'---\ntitle: Three dashes marks the spot\ntags:\n - yaml\n - front-matter\n - dashes\nexpaned-'
30
)
31
t.end()
32
})
33
34
test('base64: tab characters in base64 - should get stripped', function (t) {
35
t.equal(
36
new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK\t\t\t\tICAtIHlhbWwKICAtIGZyb250LW1hdHRlcgogIC0gZGFzaGVzCmV4cGFuZWQt', 'base64').toString('utf8'),
37
'---\ntitle: Three dashes marks the spot\ntags:\n - yaml\n - front-matter\n - dashes\nexpaned-'
38
)
39
t.end()
40
})
41
42
43