(str)
| 11336 | var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g |
| 11337 | |
| 11338 | function base64clean (str) { |
| 11339 | // Node strips out invalid characters like \n and \t from the string, base64-js does not |
| 11340 | str = stringtrim(str).replace(INVALID_BASE64_RE, '') |
| 11341 | // Node converts strings with length < 2 to '' |
| 11342 | if (str.length < 2) return '' |
| 11343 | // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not |
| 11344 | while (str.length % 4 !== 0) { |
| 11345 | str = str + '=' |
| 11346 | } |
| 11347 | return str |
| 11348 | } |
| 11349 | |
| 11350 | function stringtrim (str) { |
| 11351 | if (str.trim) return str.trim() |
no test coverage detected