MCPcopy Create free account
hub / github.com/reactjs/react-rails / base64clean

Function base64clean

lib/assets/javascripts/JSXTransformer.js:1617–1627  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

1615var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
1616
1617function 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
1629function stringtrim (str) {
1630 if (str.trim) return str.trim()

Callers 1

base64ToBytesFunction · 0.85

Calls 1

stringtrimFunction · 0.85

Tested by

no test coverage detected