(str)
| 2240 | var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g |
| 2241 | |
| 2242 | function base64clean (str) { |
| 2243 | // Node strips out invalid characters like \n and \t from the string, base64-js does not |
| 2244 | str = stringtrim(str).replace(INVALID_BASE64_RE, '') |
| 2245 | // Node converts strings with length < 2 to '' |
| 2246 | if (str.length < 2) return '' |
| 2247 | // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not |
| 2248 | while (str.length % 4 !== 0) { |
| 2249 | str = str + '=' |
| 2250 | } |
| 2251 | return str |
| 2252 | } |
| 2253 | |
| 2254 | function stringtrim (str) { |
| 2255 | if (str.trim) return str.trim() |
no test coverage detected