url-safe.js 577 B

123456789101112131415161718192021222324
  1. var test = require('tape')
  2. var b64 = require('../')
  3. test('decode url-safe style base64 strings', function (t) {
  4. var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]
  5. var str = '//++/++/++//'
  6. var actual = b64.toByteArray(str)
  7. for (var i = 0; i < actual.length; i++) {
  8. t.equal(actual[i], expected[i])
  9. }
  10. t.equal(b64.byteLength(str), actual.length)
  11. str = '__--_--_--__'
  12. actual = b64.toByteArray(str)
  13. for (i = 0; i < actual.length; i++) {
  14. t.equal(actual[i], expected[i])
  15. }
  16. t.equal(b64.byteLength(str), actual.length)
  17. t.end()
  18. })