MCPcopy Create free account
hub / github.com/OneNoteDev/WebClipper / base64clean

Function base64clean

lib/sanitize-html.js:2242–2252  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

2240var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
2241
2242function base64clean (str) {
2243 // Node strips out invalid characters like \n and \t from the string, base64-js does not
2244 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
2245 // Node converts strings with length < 2 to ''
2246 if (str.length < 2) return ''
2247 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2248 while (str.length % 4 !== 0) {
2249 str = str + '='
2250 }
2251 return str
2252}
2253
2254function stringtrim (str) {
2255 if (str.trim) return str.trim()

Callers 1

base64ToBytesFunction · 0.85

Calls 1

stringtrimFunction · 0.85

Tested by

no test coverage detected