Sha256: 21178bda8f9f64227b194906f66683298db48f93fcf1b6edb2febc12228debbd

Contents?: true

Size: 1.65 KB

Versions: 23

Compression:

Stored size: 1.65 KB

Contents

/* */ 
(function(process) {
  var B = require("../index").Buffer;
  var test = require("tape");
  if (process.env.OBJECT_IMPL)
    B.TYPED_ARRAY_SUPPORT = false;
  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();
  });
})(require("process"));

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
sequenceserver-2.0.0 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc8 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc7 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc6 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc5 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc4 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc3 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc2 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.rc1 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.beta4 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.beta3 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-2.0.0.beta1 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta12 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta11 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta10 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta8 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta7 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta6 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta5 public/vendor/npm/buffer@3.4.3/test/base64.js
sequenceserver-1.1.0.beta4 public/vendor/npm/buffer@3.4.3/test/base64.js