1/*! 2 * JavaScript Cookie v2.2.0 3 * https://github.com/js-cookie/js-cookie 4 * 5 * Copyright 2006, 2015 Klaus Hartl & Fagner Brack 6 * Released under the MIT license 7 */ 8 9;(function (factory) { 10 var registeredInModuleLoader = false; 11 if (typeof define === 'function' && define.amd) { 12 define(factory); 13 registeredInModuleLoader = true; 14 } 15 if (typeof exports === 'object') { 16 module.exports = factory(); 17 registeredInModuleLoader = true; 18 } 19 if (!registeredInModuleLoader) { 20 var OldCookies = window.Cookies; 21 var api = window.Cookies = factory(); 22 api.noConflict = function () { 23 window.Cookies = OldCookies; 24 return api; 25 }; 26 } 27}(function () { 28 function extend () { 29 var i = 0; 30 var result = {}; 31 for (; i < arguments.length; i++) { 32 var attributes = arguments[ i ]; 33 for (var key in attributes) { 34 result[key] = attributes[key]; 35 } 36 } 37 return result; 38 } 39 40 function init (converter) { 41 function api (key, value, attributes) { 42 var result; 43 if (typeof document === 'undefined') { 44 return; 45 } 46 47 // Write 48 49 if (arguments.length > 1) { 50 attributes = extend({ 51 path: '/' 52 }, api.defaults, attributes); 53 54 if (typeof attributes.expires === 'number') { 55 var expires = new Date(); 56 expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); 57 attributes.expires = expires; 58 } 59 60 // We're using "expires" because "max-age" is not supported by IE 61 attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; 62 63 try { 64 result = JSON.stringify(value); 65 if (/^[\{\[]/.test(result)) { 66 value = result; 67 } 68 } catch (e) {} 69 70 if (!converter.write) { 71 value = encodeURIComponent(String(value)) 72 .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 73 } else { 74 value = converter.write(value, key); 75 } 76 77 key = encodeURIComponent(String(key)); 78 key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); 79 key = key.replace(/[\(\)]/g, escape); 80 81 var stringifiedAttributes = ''; 82 83 for (var attributeName in attributes) { 84 if (!attributes[attributeName]) { 85 continue; 86 } 87 stringifiedAttributes += '; ' + attributeName; 88 if (attributes[attributeName] === true) { 89 continue; 90 } 91 stringifiedAttributes += '=' + attributes[attributeName]; 92 } 93 return (document.cookie = key + '=' + value + stringifiedAttributes); 94 } 95 96 // Read 97 98 if (!key) { 99 result = {}; 100 } 101 102 // To prevent the for loop in the first place assign an empty array 103 // in case there are no cookies at all. Also prevents odd result when 104 // calling "get()" 105 var cookies = document.cookie ? document.cookie.split('; ') : []; 106 var rdecode = /(%[0-9A-Z]{2})+/g; 107 var i = 0; 108 109 for (; i < cookies.length; i++) { 110 var parts = cookies[i].split('='); 111 var cookie = parts.slice(1).join('='); 112 113 if (!this.json && cookie.charAt(0) === '"') { 114 cookie = cookie.slice(1, -1); 115 } 116 117 try { 118 var name = parts[0].replace(rdecode, decodeURIComponent); 119 cookie = converter.read ? 120 converter.read(cookie, name) : converter(cookie, name) || 121 cookie.replace(rdecode, decodeURIComponent); 122 123 if (this.json) { 124 try { 125 cookie = JSON.parse(cookie); 126 } catch (e) {} 127 } 128 129 if (key === name) { 130 result = cookie; 131 break; 132 } 133 134 if (!key) { 135 result[name] = cookie; 136 } 137 } catch (e) {} 138 } 139 140 return result; 141 } 142 143 api.set = api; 144 api.get = function (key) { 145 return api.call(api, key); 146 }; 147 api.getJSON = function () { 148 return api.apply({ 149 json: true 150 }, [].slice.call(arguments)); 151 }; 152 api.defaults = {}; 153 154 api.remove = function (key, attributes) { 155 api(key, '', extend(attributes, { 156 expires: -1 157 })); 158 }; 159 160 api.withConverter = init; 161 162 return api; 163 } 164 165 return init(function () {}); 166})); 167 168function QueryToJson(queryString) { 169 const params = {}; 170 171 if (!queryString) { 172 return params; 173 } 174 175 const pairs = queryString.split('&'); 176 177 for (const pair of pairs) { 178 const [key, value] = pair.split('='); 179 if (key) { 180 let decodedKey, decodedValue; 181
182 try { 183 decodedKey = decodeURIComponent(key); 184 } catch (e) { 185 if (typeof window !== 'undefined' 186 && window.Sentry 187 && window.Sentry.captureException 188 ) { 189 window.Sentry.captureException(new Error('URL parameter key decoding failed'), { 190 tags: { 191 error_type: 'url_decode_failure', 192 component: 'referral_query_parser', 193 param_type: 'key' 194 }, 195 extra: { 196 original_key: key, 197 query_string: queryString, 198 error_message: e.message, 199 stack_trace: e.stack, 200 timestamp: new Date().toISOString(), 201 page_url: typeof window !== 'undefined' ? window.location.href : 'unknown' 202 }, 203 level: 'warning' 204 }); 205 } 206 decodedKey = key; 207 } 208 209 try { 210 decodedValue = value ? decodeURIComponent(value) : ''; 211 } catch (e) { 212 if (typeof window !== 'undefined' 213 && window.Sentry 214 && window.Sentry.captureException 215 ) { 216 window.Sentry.captureException(new Error('URL parameter value decoding failed'), { 217 tags: { 218 error_type: 'url_decode_failure', 219 component: 'referral_query_parser', 220 param_type: 'value' 221 }, 222 extra: { 223 original_value: value, 224 decoded_key: decodedKey, 225 query_string: queryString, 226 error_message: e.message, 227 stack_trace: e.stack, 228 timestamp: new Date().toISOString(), 229 page_url: typeof window !== 'undefined' ? window.location.href : 'unknown' 230 }, 231 level: 'warning' 232 }); 233 } 234 decodedValue = value || ''; 235 } 236 237 params[decodedKey] = decodedValue; 238 } 239 } 240 241 return params; 242} 243 244window.addEventListener('DOMContentLoaded', () => { 245 if (window.location.href.includes('referral_id')) { 246 const params = QueryToJson(window.location.search.substr(1)) 247 Cookies.set('referral_id', params && params.referral_id) 248 } 249});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.