(str)
| 1938 | const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g |
| 1939 | |
| 1940 | function base64clean (str) { |
| 1941 | // Node takes equal signs as end of the Base64 encoding |
| 1942 | str = str.split('=')[0] |
| 1943 | // Node strips out invalid characters like \n and \t from the string, base64-js does not |
| 1944 | str = str.trim().replace(INVALID_BASE64_RE, '') |
| 1945 | // Node converts strings with length < 2 to '' |
| 1946 | if (str.length < 2) return '' |
| 1947 | // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not |
| 1948 | while (str.length % 4 !== 0) { |
| 1949 | str = str + '=' |
| 1950 | } |
| 1951 | return str |
| 1952 | } |
| 1953 | |
| 1954 | function utf8ToBytes (string, units) { |
| 1955 | units = units || Infinity |
no outgoing calls
no test coverage detected
searching dependent graphs…