-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompact-base64.js
1 lines (1 loc) · 1.67 KB
/
compact-base64.js
1
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.Base64=r():e.Base64=r()}(self,(()=>(()=>{"use strict";var e={110:(e,r,n)=>{e.exports=n(126)((function(e,r){var n="",t=[];if(/^utf-?(8|16)$/i.test(r)||!r)encodeURIComponent(e).replace(/%([0-9A-F]{2})|./g,(function(e,r){t.push(r?parseInt(r,16):e.charCodeAt(0))}));else if("hex"===r)e.replace(/[0-9A-F]{2}/gi,(function(e){t.push(parseInt(e,16))}));else{if("binary"!==r)throw new Error("Invalid inputEncoding supplied");t=e}return t.forEach((function(e){var r=("00"+e.toString(16)).slice(-2);n+=String.fromCharCode("0x"+r)})),btoa(n)}),(function(e,r){var n=Array.prototype.map.call(atob(e),(function(e){return e.charCodeAt(0)}));if("binary"===r)return n;if("hex"===r)return n.map((function(e){return("00"+e.toString(16)).slice(-2)})).join("");if(/^utf-?(8|16)$/i.test(r)||!r)return decodeURIComponent(n.map((function(e){return"%"+("00"+e.toString(16)).slice(-2)})).join(""));throw new Error("Invalid outputEncoding supplied")}))},126:e=>{var r=/[+/=]/g,n=/[-_]/g,t=function(e){return e.replace(r,(function(e){return"="==e?"":"+"==e?"-":"/"==e?"_":void 0}))},o=function(e){return i(e.replace(n,(function(e){return"-"==e?"+":"_"==e?"/":void 0})))},i=function(e){var r=4-e.length%4;return 4!==r&&(e+="====".slice(0,r)),e};e.exports=function(e,r){var n={};return n.originalToUrl=t,n.urlToOriginal=o,n.encode=e,n.decode=r,n.encodeUrl=function(r,n){return t(e(r,n))},n.decodeUrl=function(e,n){return r(o(e),n)},n}}},r={};return function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}(110)})()));