Skip to content

Commit

Permalink
allow decoding url-safe base64 space and slash
Browse files Browse the repository at this point in the history
  • Loading branch information
jessetane committed Dec 22, 2014
1 parent 7ba48f8 commit 3945e4c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,8 @@ var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
// replace url-safe space and slash
str = str.replace(/-/g, '+').replace(/_/g, '/')
// Node converts strings with length < 2 to ''
if (str.length < 2) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
Expand Down

0 comments on commit 3945e4c

Please sign in to comment.