Sha256: 0b9cf24547d72d6e2c52be885b26cd95b79cd2ed65d894854e3b31cc199b8edc

Contents?: true

Size: 1.58 KB

Versions: 43

Compression:

Stored size: 1.58 KB

Contents

if (process.env.OBJECT_IMPL) global.TYPED_ARRAY_SUPPORT = false
var B = require('../').Buffer
var test = require('tape')

test('base64: ignore whitespace', function (t) {
  var text = '\n   YW9ldQ==  '
  var buf = new B(text, 'base64')
  t.equal(buf.toString(), 'aoeu')
  t.end()
})

test('base64: strings without padding', function (t) {
  t.equal((new B('YW9ldQ', 'base64').toString()), 'aoeu')
  t.end()
})

test('base64: newline in utf8 -- should not be an issue', function (t) {
  t.equal(
    new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK', 'base64').toString('utf8'),
    '---\ntitle: Three dashes marks the spot\ntags:\n'
  )
  t.end()
})

test('base64: newline in base64 -- should get stripped', function (t) {
  t.equal(
    new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK\nICAtIHlhbWwKICAtIGZyb250LW1hdHRlcgogIC0gZGFzaGVzCmV4cGFuZWQt', 'base64').toString('utf8'),
    '---\ntitle: Three dashes marks the spot\ntags:\n  - yaml\n  - front-matter\n  - dashes\nexpaned-'
  )
  t.end()
})

test('base64: tab characters in base64 - should get stripped', function (t) {
  t.equal(
    new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK\t\t\t\tICAtIHlhbWwKICAtIGZyb250LW1hdHRlcgogIC0gZGFzaGVzCmV4cGFuZWQt', 'base64').toString('utf8'),
    '---\ntitle: Three dashes marks the spot\ntags:\n  - yaml\n  - front-matter\n  - dashes\nexpaned-'
  )
  t.end()
})

test('base64: invalid non-alphanumeric characters -- should be stripped', function (t) {
  t.equal(
    new B('!"#$%&\'()*,.:;<=>?@[\\]^`{|}~', 'base64').toString('utf8'),
    ''
  )
  t.end()
})

Version data entries

43 entries across 42 versions & 15 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/buffer/test/base64.js
disco_app-0.18.0 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.18.2 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.16.1 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.15.2 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.18.4 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.18.1 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.14.0 test/dummy/node_modules/buffer/test/base64.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/buffer/test/base64.js
tang-0.2.1 spec/tang_app/node_modules/buffer/test/base64.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/buffer/test/base64.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/buffer/test/base64.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/buffer/test/base64.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/buffer/test/base64.js
tang-0.2.0 spec/tang_app/node_modules/buffer/test/base64.js
tang-0.1.0 spec/tang_app/node_modules/buffer/test/base64.js
tang-0.0.9 spec/tang_app/node_modules/buffer/test/base64.js
enju_library-0.3.8 spec/dummy/node_modules/buffer/test/base64.js
ilog-0.4.1 node_modules/buffer/test/base64.js