UNPKG

@shopware/api-client

Version:
14 lines (10 loc) 394 B
'use strict'; const fflate = require('fflate'); function encodeForQuery(obj) { const json = JSON.stringify(obj); const compressed = fflate.gzipSync(fflate.strToU8(json)); let base64 = btoa(String.fromCharCode.apply(null, Array.from(compressed))); base64 = base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); return base64; } exports.encodeForQuery = encodeForQuery;