From: Jesse Tane Date: Mon, 22 Dec 2014 16:10:30 +0000 (-0500) Subject: allow decoding url-safe base64 space and slash X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=767070ece98af730d110e4905aa454db6a4a9a4c;p=buffer.git allow decoding url-safe base64 space and slash --- 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