summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/strings/quoted_printable_encode.js.map
blob: 2be312f71b2b5404d26675df8e386e938096c756 (plain) (blame)
1
{"version":3,"sources":["../../../src/php/strings/quoted_printable_encode.js"],"names":["module","exports","quoted_printable_encode","str","hexChars","RFC2045Encode1IN","RFC2045Encode1OUT","sMatch","length","replace","chr","charCodeAt","RFC2045Encode2IN","RFC2045Encode2OUT","substr"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,uBAAT,CAAkCC,GAAlC,EAAuC;AAAE;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,WAAW,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,EAAqB,GAArB,EAA0B,GAA1B,EAA+B,GAA/B,EAAoC,GAApC,EAAyC,GAAzC,EAA8C,GAA9C,EAAmD,GAAnD,EAAwD,GAAxD,EAA6D,GAA7D,EAAkE,GAAlE,EAAuE,GAAvE,EAA4E,GAA5E,CAAf;AACA,MAAIC,mBAAmB,yBAAvB;AACA,MAAIC,oBAAoB,SAApBA,iBAAoB,CAAUC,MAAV,EAAkB;AACxC;AACA;AACA,QAAIA,OAAOC,MAAP,GAAgB,CAApB,EAAuB;AACrB,aAAOD,OAAOE,OAAP,CAAe,GAAf,EAAoB,KAApB,CAAP;AACD;AACD;AACA,QAAIC,MAAMH,OAAOI,UAAP,CAAkB,CAAlB,CAAV;AACA,WAAO,MAAMP,SAAWM,QAAQ,CAAT,GAAc,EAAxB,CAAN,GAAqCN,SAAUM,MAAM,EAAhB,CAA5C;AACD,GATD;;AAWA;AACA;AACA;AACA;;AAEA,MAAIE,mBAAmB,2BAAvB;AACA,MAAIC,oBAAoB,SAApBA,iBAAoB,CAAUN,MAAV,EAAkB;AACxC,QAAIA,OAAOO,MAAP,CAAcP,OAAOC,MAAP,GAAgB,CAA9B,MAAqC,MAAzC,EAAiD;AAC/C,aAAOD,MAAP;AACD;AACD,WAAOA,SAAS,OAAhB;AACD,GALD;;AAOAJ,QAAMA,IACHM,OADG,CACKJ,gBADL,EACuBC,iBADvB,EAEHG,OAFG,CAEKG,gBAFL,EAEuBC,iBAFvB,CAAN;;AAIA;AACA,SAAOV,IAAIW,MAAJ,CAAW,CAAX,EAAcX,IAAIK,MAAJ,GAAa,CAA3B,CAAP;AACD,CA7CD","file":"quoted_printable_encode.js","sourcesContent":["module.exports = function quoted_printable_encode (str) { // eslint-disable-line camelcase\n  //  discuss at: http://locutus.io/php/quoted_printable_encode/\n  // original by: Theriault (https://github.com/Theriault)\n  // improved by: Brett Zamir (http://brett-zamir.me)\n  // improved by: Theriault (https://github.com/Theriault)\n  //   example 1: quoted_printable_encode('a=b=c')\n  //   returns 1: 'a=3Db=3Dc'\n  //   example 2: quoted_printable_encode('abc   \\r\\n123   \\r\\n')\n  //   returns 2: 'abc  =20\\r\\n123  =20\\r\\n'\n  //   example 3: quoted_printable_encode('0123456789012345678901234567890123456789012345678901234567890123456789012345')\n  //   returns 3: '012345678901234567890123456789012345678901234567890123456789012345678901234=\\r\\n5'\n  //        test: skip-2\n\n  var hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']\n  var RFC2045Encode1IN = / \\r\\n|\\r\\n|[^!-<>-~ ]/gm\n  var RFC2045Encode1OUT = function (sMatch) {\n    // Encode space before CRLF sequence to prevent spaces from being stripped\n    // Keep hard line breaks intact; CRLF sequences\n    if (sMatch.length > 1) {\n      return sMatch.replace(' ', '=20')\n    }\n    // Encode matching character\n    var chr = sMatch.charCodeAt(0)\n    return '=' + hexChars[((chr >>> 4) & 15)] + hexChars[(chr & 15)]\n  }\n\n  // Split lines to 75 characters; the reason it's 75 and not 76 is because softline breaks are\n  // preceeded by an equal sign; which would be the 76th character. However, if the last line/string\n  // was exactly 76 characters, then a softline would not be needed. PHP currently softbreaks\n  // anyway; so this function replicates PHP.\n\n  var RFC2045Encode2IN = /.{1,72}(?!\\r\\n)[^=]{0,3}/g\n  var RFC2045Encode2OUT = function (sMatch) {\n    if (sMatch.substr(sMatch.length - 2) === '\\r\\n') {\n      return sMatch\n    }\n    return sMatch + '=\\r\\n'\n  }\n\n  str = str\n    .replace(RFC2045Encode1IN, RFC2045Encode1OUT)\n    .replace(RFC2045Encode2IN, RFC2045Encode2OUT)\n\n  // Strip last softline break\n  return str.substr(0, str.length - 3)\n}\n"]}