MCPcopy Create free account
hub / github.com/TruthHun/BookStack / base64clean

Function base64clean

static/word2md/mammoth.browser.js:11338–11348  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

11336var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
11337
11338function base64clean (str) {
11339 // Node strips out invalid characters like \n and \t from the string, base64-js does not
11340 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
11341 // Node converts strings with length < 2 to ''
11342 if (str.length < 2) return ''
11343 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
11344 while (str.length % 4 !== 0) {
11345 str = str + '='
11346 }
11347 return str
11348}
11349
11350function stringtrim (str) {
11351 if (str.trim) return str.trim()

Callers 1

base64ToBytesFunction · 0.70

Calls 1

stringtrimFunction · 0.70

Tested by

no test coverage detected