Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/urlsafe-base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ exports.decode = function decode(base64) {
.replace(/\-/g, '+') // Convert '-' to '+'
.replace(/\_/g, '/'); // Convert '_' to '/'

return new Buffer(base64, 'base64');
return Buffer.from(base64, 'base64');

};

Expand Down
28 changes: 16 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
"name": "urlsafe-base64",
"version": "1.0.0",
"description": "URL Safe Base64 encoding",
"keywords": ["base64", "encoding", "url", "util"],
"keywords": [
"base64",
"encoding",
"url",
"util"
],
"author": "RGBboy <l-_-l@rgbboy.com>",
"repository" : {
"type" : "git",
"url" : "http://github.com/RGBboy/urlsafe-base64"
"repository": {
"type": "git",
"url": "http://github.com/RGBboy/urlsafe-base64"
},
"main": "index",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"mocha": "1.5.x",
"should": "1.2.x"
"mocha": "5.2.0",
"should": "13.2.3"
},
"scripts" : {
"test" : "make test",
"unit" : "make unit"
"scripts": {
"test": "make test",
"unit": "make unit"
}
}
}
4 changes: 2 additions & 2 deletions test/urlsafe-base64.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('URL Safe Base64', function () {

it('should encode a buffer correctly', function (done) {
var testBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
testBuffer = new Buffer(testBase64, 'base64'),
testBuffer = Buffer.from(testBase64, 'base64'),
expectedBase64 = testBase64.replace('+', '-').replace('/', '_');
URLSafeBase64.encode(testBuffer).should.equal(expectedBase64);
done();
Expand All @@ -52,7 +52,7 @@ describe('URL Safe Base64', function () {
it('should decode a base64 string correctly', function (done) {
var encodedBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/',
normalBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
testBuffer = new Buffer(normalBase64, 'base64'),
testBuffer = Buffer.from(normalBase64, 'base64'),
decoded = URLSafeBase64.decode(encodedBase64);
decoded.should.be.an.instanceof(Buffer);
decoded.toString('utf8').should.equal(testBuffer.toString('utf8'));
Expand Down