From 767070ece98af730d110e4905aa454db6a4a9a4c Mon Sep 17 00:00:00 2001 From: Jesse Tane Date: Mon, 22 Dec 2014 11:10:30 -0500 Subject: [PATCH] allow decoding url-safe base64 space and slash --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index f01d6ac..072ec7f 100644 --- a/index.js +++ b/index.js @@ -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 -- 2.34.1