All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.esm.cookie.js.map Maven / Gradle / Ivy

The newest version!
{"version":3,"file":"cookie.js","sources":["../../src/cookie.ts"],"sourcesContent":["/**\n * This code was originally copied from the 'cookie` module at v0.5.0 and was simplified for our use case.\n * https://github.com/jshttp/cookie/blob/a0c84147aab6266bdb3996cf4062e93907c0b0fc/index.js\n * It had the following license:\n *\n * (The MIT License)\n *\n * Copyright (c) 2012-2014 Roman Shtylman \n * Copyright (c) 2015 Douglas Christopher Wilson \n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * 'Software'), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Parses a cookie string\n */\nexport function parseCookie(str: string): Record {\n  const obj: Record = {};\n  let index = 0;\n\n  while (index < str.length) {\n    const eqIdx = str.indexOf('=', index);\n\n    // no more cookie pairs\n    if (eqIdx === -1) {\n      break;\n    }\n\n    let endIdx = str.indexOf(';', index);\n\n    if (endIdx === -1) {\n      endIdx = str.length;\n    } else if (endIdx < eqIdx) {\n      // backtrack on prior semicolon\n      index = str.lastIndexOf(';', eqIdx - 1) + 1;\n      continue;\n    }\n\n    const key = str.slice(index, eqIdx).trim();\n\n    // only assign once\n    if (undefined === obj[key]) {\n      let val = str.slice(eqIdx + 1, endIdx).trim();\n\n      // quoted values\n      if (val.charCodeAt(0) === 0x22) {\n        val = val.slice(1, -1);\n      }\n\n      try {\n        obj[key] = val.indexOf('%') !== -1 ? decodeURIComponent(val) : val;\n      } catch (e) {\n        obj[key] = val;\n      }\n    }\n\n    index = endIdx + 1;\n  }\n\n  return obj;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,SAAS,WAAW,CAAC,GAAG,EAAkC;AACjE,EAAE,MAAM,GAAG,GAA2B,EAAE;AACxC,EAAE,IAAI,KAAM,GAAE,CAAC;;AAEf,EAAE,OAAO,KAAA,GAAQ,GAAG,CAAC,MAAM,EAAE;AAC7B,IAAI,MAAM,KAAM,GAAE,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;;AAEzC;AACA,IAAI,IAAI,KAAA,KAAU,CAAC,CAAC,EAAE;AACtB,MAAM;AACN;;AAEA,IAAI,IAAI,MAAO,GAAE,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;;AAExC,IAAI,IAAI,MAAA,KAAW,CAAC,CAAC,EAAE;AACvB,MAAM,MAAO,GAAE,GAAG,CAAC,MAAM;AACzB,WAAW,IAAI,MAAO,GAAE,KAAK,EAAE;AAC/B;AACA,MAAM,KAAM,GAAE,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,KAAM,GAAE,CAAC,CAAA,GAAI,CAAC;AACjD,MAAM;AACN;;AAEA,IAAI,MAAM,GAAA,GAAM,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CA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