From 19beb55ec8dd78ba162c291d6ff25eee2241c6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Nowotka?= Date: Wed, 12 Feb 2014 09:46:57 +0000 Subject: [PATCH] Add url safe encoding/decoding Add url safe encoding/decoding compatible with http://docs.python.org/2/library/base64.html#base64.urlsafe_b64encode. --- jquery.base64.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jquery.base64.js b/jquery.base64.js index 8cda79d..ee4c95a 100644 --- a/jquery.base64.js +++ b/jquery.base64.js @@ -178,11 +178,22 @@ jQuery.base64 = ( function( $ ) { return x.join( "" ); } + + function _urlsafe_encode( s ) { + return _encode(s).replace(/\+/g, '-').replace(/\//g, '_'); + } + + + function _urlsafe_decode( s ) { + return _decode(s).replace(/\-/g, '+').replace(/\_/g, '/'); + } return { decode: _decode, encode: _encode, + urlsafe_decode: _urlsafe_decode, + urlsafe_encode: _urlsafe_encode, VERSION: _VERSION };