base64-url
Advanced tools
Comparing version
11
index.js
@@ -1,9 +0,14 @@ | ||
var base64url = exports; | ||
var base64url = module.exports; | ||
base64url.unescape = function unescape (str) { | ||
return (str + Array(5 - str.length % 4).join('=')).replace(/\-/g,'+').replace(/_/g, '/'); | ||
return (str + Array(5 - str.length % 4) | ||
.join('=')) | ||
.replace(/\-/g, '+') | ||
.replace(/_/g, '/'); | ||
}; | ||
base64url.escape = function escape (str) { | ||
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | ||
return str.replace(/\+/g, '-') | ||
.replace(/\//g, '_') | ||
.replace(/=/g, ''); | ||
}; | ||
@@ -10,0 +15,0 @@ |
{ | ||
"name": "base64-url", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Base64 encode, decode, escape and unescape for URL applications", | ||
@@ -10,3 +10,7 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "node test" | ||
"test": "./node_modules/istanbul/lib/cli.js cover ./node_modules/tape/bin/tape test.js", | ||
"jshint": "./node_modules/jshint/bin/jshint -c .jshintrc *.js", | ||
"codestyle": "./node_modules/jscs/bin/jscs -p google *.js", | ||
"check-coverage": "./node_modules/istanbul/lib/cli.js check-coverage --statements 100 --functions 100 --lines 100 --branches 100", | ||
"coverage": "open coverage/lcov-report/index.html" | ||
}, | ||
@@ -26,6 +30,30 @@ "repository": { | ||
}, | ||
"testling": { | ||
"files": "test.js", | ||
"browsers": [ | ||
"ie/6..latest", | ||
"chrome/22..latest", | ||
"firefox/16..latest", | ||
"safari/latest", | ||
"opera/11.0..latest", | ||
"iphone/6", | ||
"ipad/6", | ||
"android-browser/latest" | ||
] | ||
}, | ||
"homepage": "https://github.com/joaquimserafim/base64-url", | ||
"devDependencies": { | ||
"tape": "^2.12.3" | ||
} | ||
"istanbul": "^0.3.5", | ||
"jscs": "^1.9.0", | ||
"jshint": "^2.5.11", | ||
"pre-commit": "0.0.9", | ||
"tape": "^3.0.3", | ||
"which": "^1.0.8" | ||
}, | ||
"pre-commit": [ | ||
"jshint", | ||
"codestyle", | ||
"test", | ||
"check-coverage" | ||
] | ||
} |
@@ -10,19 +10,27 @@ # base64-url | ||
**V1.1** | ||
**V1** | ||
**code coverage:** | ||
`npm test && npm run check-coverage && npm run coverage` | ||
**codestyle:** | ||
`npm run codestyle` | ||
**jshint:** | ||
`npm run jshint` | ||
####API | ||
> base64url.encode('Node.js is awesome.'); | ||
Tm9kZS5qcyBpcyBhd2Vzb21lLg | ||
> base64url.encode('Node.js is awesome.'); | ||
Tm9kZS5qcyBpcyBhd2Vzb21lLg | ||
> base64url.decode('Tm9kZS5qcyBpcyBhd2Vzb21lLg'); | ||
Node.js is awesome. | ||
> base64url.escape(This+is/goingto+escape==); | ||
This-is_goingto-escape | ||
> base64url.decode('Tm9kZS5qcyBpcyBhd2Vzb21lLg'); | ||
Node.js is awesome. | ||
> base64url.escape('This+is/goingto+escape=='); | ||
This-is_goingto-escape | ||
> base64url.unescape('This-is_goingto-escape'); | ||
This+is/goingto+escape== | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4680
33.75%36
24.14%36
33.33%6
500%