MCPcopy Create free account
hub / github.com/UI5/webcomponents / base64clean

Function base64clean

packages/main/test/pages/diffable-html.js:1713–1725  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

1711 var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
1712
1713 function base64clean (str) {
1714 // Node takes equal signs as end of the Base64 encoding
1715 str = str.split('=')[0]
1716 // Node strips out invalid characters like \n and \t from the string, base64-js does not
1717 str = str.trim().replace(INVALID_BASE64_RE, '')
1718 // Node converts strings with length < 2 to ''
1719 if (str.length < 2) return ''
1720 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1721 while (str.length % 4 !== 0) {
1722 str = str + '='
1723 }
1724 return str
1725 }
1726
1727 function toHex (n) {
1728 if (n < 16) return '0' + n.toString(16)

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…