Open thomasmarr opened 2 years ago
I agree, in my context, cookies are urlEncoded once more by a mechanism I have no control on and I had to patch the module to allow encode to be modified same as other ones.
diff --git a/node_modules/express-session/session/cookie.js b/node_modules/express-session/session/cookie.js
index a8b4e57..5fa4553 100644
--- a/node_modules/express-session/session/cookie.js
+++ b/node_modules/express-session/session/cookie.js
@@ -73,6 +73,28 @@ Cookie.prototype = {
return this._expires;
},
+ /**
+ * Set encode `callback`.
+ *
+ * @param {CallableFunction} callback
+ * @api public
+ */
+
+ set encode(callback) {
+ this.callback = callback;
+ },
+
+ /**
+ * Get encode `callback`.
+ *
+ * @return {CallableFunction} callback
+ * @api public
+ */
+
+ get encode() {
+ return this.callback;
+ },
+
/**
* Set expires via max-age in `ms`.
*
@@ -123,6 +145,7 @@ Cookie.prototype = {
, domain: this.domain
, path: this.path
, sameSite: this.sameSite
+ , encode: this.callback
}
},
One of the options which can be set on
cookie.serialize
isencode
see hereIn
express-session
it is not possible to set this option:I believe express-session should expose this, as the default
encodeUriComponent
is not always the desired behaviour. I would be willing to try and put a PR together for this if it was likely to be merged promptly.