Skip to content

best way to save what you love

api/cookie: formatting

jj2351cf74f447
diff --git a/api/src/processing/cookie/cookie.js b/api/src/processing/cookie/cookie.js
index 6dd95fc3..5a3f6dcd 100644
--- a/api/src/processing/cookie/cookie.js
+++ b/api/src/processing/cookie/cookie.js
@@ -6,14 +6,17 @@ export default class Cookie {
this._values = {};
this.set(input)
}
+
set(values) {
Object.entries(values).forEach(
([ key, value ]) => this._values[key] = value
)
}
+
unset(keys) {
for (const key of keys) delete this._values[key]
}
+
static fromString(str) {
const obj = {};
@@ -25,12 +28,15 @@ export default class Cookie {
return new Cookie(obj)
}
+
toString() {
return Object.entries(this._values).map(([ name, value ]) => `${name}=${value}`).join('; ')
}
+
toJSON() {
return this.toString()
}
+
values() {
return Object.freeze({ ...this._values })
}