Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent) error #530

Closed
chenlong07253 opened this issue Aug 29, 2019 · 4 comments
Closed

s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent) error #530

chenlong07253 opened this issue Aug 29, 2019 · 4 comments

Comments

@chenlong07253
Copy link

image
你好,我们在用js-cookie的时候发现一个兼容问题,我们的后端是.net,编码后的字符串是小写, js取不到相应的cookie。

Hello, we found a compatibility problem when using js-cookie. Our backend is. net, the encoding string is lowercase, JS can not get the corresponding cookie.

"%e5%9c%a8%e5%b8%8c%e6%9c%9b%e7%9a%84%e7%94%b0%e9%87%8e%e4%b8%8a".replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent)

@carhartl
Copy link
Member

In case you want to read a cookie that has been provided by some server-side web framework you may need to use a custom (read) converter:

https://github.com/js-cookie/js-cookie/blob/master/README.md#read

It is impossible for us to ensure compatibility with the many different web frameworks out there, instead we chose to be RFC 6265 compliant:

https://github.com/js-cookie/js-cookie/blob/master/README.md#encoding

Converters allow to divert from that encoding strategy and provide a custom decoder, and encoder, being compatible with your backend.

@chenlong07253
Copy link
Author

Thank you for your explanation.

@carhartl
Copy link
Member

carhartl commented Oct 6, 2019

@chenlong07253

This is now fixed in v3 and we support such lowercase url encoded cookie values!

@carhartl
Copy link
Member

carhartl commented Oct 6, 2019

(I only realized now that this is the same as #466...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants