Skip to content

Commit 0264aad

Browse files
Add docs for Tomcat
Closes js-cookiegh-92.
1 parent dbc7add commit 0264aad

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

SERVERS.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,22 @@ var Cookies = Cookies.withConverter({
3636
});
3737
```
3838

39-
Rack seems to have [a similar problem](https://github.com/js-cookie/js-cookie/issues/70#issuecomment-132503017).
39+
Rack seems to have [a similar problem](https://github.com/js-cookie/js-cookie/issues/70#issuecomment-132503017).
40+
41+
## Tomcat 7.x
42+
43+
It seems that there is a situation where Tomcat does not [read the parens correctly](https://github.com/js-cookie/js-cookie/issues/92#issue-107743407). To fix this you need to write a custom write converter:
44+
45+
```javascript
46+
var Cookies = Cookies.withConverter({
47+
write: function (value) {
48+
// Encode all characters according to the "encodeURIComponent" spec
49+
return encodeURIComponent(value)
50+
// Revert the characters that are unnecessarly encoded but are
51+
// allowed in a cookie value
52+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent)
53+
// Encode the parens that are interpreted incorrectly by Tomcat
54+
.replace(/[\(\)]/g, escape);
55+
}
56+
});
57+
```

0 commit comments

Comments
 (0)