MCPcopy
hub / github.com/feross/buffer / base64clean

Function base64clean

index.js:1940–1952  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

1938const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
1939
1940function 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
1954function utf8ToBytes (string, units) {
1955 units = units || Infinity

Callers 1

base64ToBytesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…