Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Changing the behaviour to enable handling URL safe base64 strings. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
7 changes: 4 additions & 3 deletions jquery.base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jQuery.base64 = ( function( $ ) {
_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
_VERSION = "1.0";


function _getbyte64( s, i ) {
// This is oddly fast, except on Chrome/V8.
// Minimal or no improvement in performance by using a
Expand Down Expand Up @@ -93,8 +92,10 @@ jQuery.base64 = ( function( $ ) {
return s;
}

if ( imax % 4 !== 0 ) {
throw "Cannot decode base64";
// handle base64 URL safe strings
while ( imax % 4 !== 0 ) {
s += '=';
imax = s.length;
}

if ( s.charAt( imax - 1 ) === _PADCHAR ) {
Expand Down
2 changes: 1 addition & 1 deletion jquery.base64.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.