|
|
@ -8,22 +8,17 @@
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
(function () {
|
|
|
|
// Intentionally called CookiesStore instead of CookieStore
|
|
|
|
let INT = undefined;
|
|
|
|
// Calling it CookieStore causes issues when the Experimental Web Platform features flag is enabled in Chrome
|
|
|
|
const Cls = (this.CookiesStore = class CookiesStore {
|
|
|
|
// Related issue: https://github.com/freeCodeCamp/devdocs/issues/932
|
|
|
|
static initClass() {
|
|
|
|
class CookiesStore {
|
|
|
|
// Intentionally called CookiesStore instead of CookieStore
|
|
|
|
static INT = /^\d+$/;
|
|
|
|
// Calling it CookieStore causes issues when the Experimental Web Platform features flag is enabled in Chrome
|
|
|
|
|
|
|
|
// Related issue: https://github.com/freeCodeCamp/devdocs/issues/932
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INT = /^\d+$/;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static onBlocked() {}
|
|
|
|
static onBlocked() {}
|
|
|
|
|
|
|
|
|
|
|
|
get(key) {
|
|
|
|
get(key) {
|
|
|
|
let value = Cookies.get(key);
|
|
|
|
let value = Cookies.get(key);
|
|
|
|
if (value != null && INT.test(value)) {
|
|
|
|
if (value != null && CookiesStore.INT.test(value)) {
|
|
|
|
value = parseInt(value, 10);
|
|
|
|
value = parseInt(value, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
@ -40,13 +35,15 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
value &&
|
|
|
|
value &&
|
|
|
|
(typeof INT.test === "function" ? INT.test(value) : undefined)
|
|
|
|
(typeof CookiesStore.INT.test === "function"
|
|
|
|
|
|
|
|
? CookiesStore.INT.test(value)
|
|
|
|
|
|
|
|
: undefined)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
value = parseInt(value, 10);
|
|
|
|
value = parseInt(value, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Cookies.set(key, "" + value, { path: "/", expires: 1e8 });
|
|
|
|
Cookies.set(key, "" + value, { path: "/", expires: 1e8 });
|
|
|
|
if (this.get(key) !== value) {
|
|
|
|
if (this.get(key) !== value) {
|
|
|
|
this.constructor.onBlocked(key, value, this.get(key));
|
|
|
|
CookiesStore.onBlocked(key, value, this.get(key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -73,7 +70,4 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
Cls.initClass();
|
|
|
|
|
|
|
|
return Cls;
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|