(str)
| 1615 | var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g |
| 1616 | |
| 1617 | function base64clean (str) { |
| 1618 | // Node strips out invalid characters like \n and \t from the string, base64-js does not |
| 1619 | str = stringtrim(str).replace(INVALID_BASE64_RE, '') |
| 1620 | // Node converts strings with length < 2 to '' |
| 1621 | if (str.length < 2) return '' |
| 1622 | // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not |
| 1623 | while (str.length % 4 !== 0) { |
| 1624 | str = str + '=' |
| 1625 | } |
| 1626 | return str |
| 1627 | } |
| 1628 | |
| 1629 | function stringtrim (str) { |
| 1630 | if (str.trim) return str.trim() |
no test coverage detected