@shopware/api-client
Version:
Shopware client for API connection.
14 lines (10 loc) • 394 B
JavaScript
;
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;