JavaScript-编码字符和URI畸形错误
我最近有一个错误,当我尝试将节点服务器发送到以下查询搜索时:
!@#$%^&*()_+
我在镀铬上遇到了一个错误:
{status: 500, message: "URI malformed"}
message: "URI malformed"
status: 500
阅读后:
您应该使用suspaive而不是Encodeuri / encodeuricomponent?
javascript decodeuri(component)畸形的URI URI异常异常 任何方法可以在JavaScript中忽略某些字符中的EncodeUricompents? /a>
编码javascript
的百分比 通过a percent (%) sign in a url and get exact value of it using php
javascript decodeuri(component)畸形的uri uli异常extivion extivion extivion
我的代码仍然无法使用
for: !@#$%^&*()_+ when I wrap my string with encodeURIComponent and in the server do decodeURIComponent.
它也无法与Encodeurl一起使用。
如果我手动替换我会得到%2525,那不好。
Any idea how to solve it?
谢谢。
我的代码:
const endpoint = `${endpoint}&text=${encodeURIComponent(query)}`;
await fetch(endpoint);
I recently have a bug, when I try to send into my node server a query search of the following:
!@#$%^&*()_+
I get an error on my Chrome:
{status: 500, message: "URI malformed"}
message: "URI malformed"
status: 500
After reading:
When are you supposed to use escape instead of encodeURI / encodeURIComponent?
Javascript decodeURI(Component) malformed uri exception
any way of making encodeURIComponent in javascript ignore certain characters?
Percent encoding javascript
Pass a percent (%) sign in a url and get exact value of it using php
Javascript decodeURI(Component) malformed uri exception
My code still won't work for: !@#$%^&*()_+ when I wrap my string with encodeURIComponent and in the server do decodeURIComponent.
It also does not work with encodeURL.
If I do manually replace I get %2525 and it's not good.
Any idea how to solve it?
Thanks.
My code:
const endpoint = `${endpoint}&text=${encodeURIComponent(query)}`;
await fetch(endpoint);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终,我的服务器端有一个错误。我试图解码“%”符号。
通过以下内容解决了:
在客户端上:
在服务器上:
Eventually there was a bug on my server side. I tried to decode the '%' sign.
Solved it by the following:
On the client:
On the server: