解码和从所有传入的请求到我的节点js应用程序 [英] Decoding & from all incoming requests to my node js app

查看:40
本文介绍了解码和从所有传入的请求到我的节点js应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简便的方法来检测和解码进入我的节点应用程序的任何URL中的所有编码字符?

Is there an easy way to detect and decode all encoded characters in any url coming to my node app ?

是否可以使用一种中间件来完成该工作,该中间件可以获取和解码& ?

can it be done with a middleware that fetch and decode symbols like & ?

推荐答案

首先,&不应位于服务器附带的URL中.如果是这样,则有人可能会对某事进行双重编码.

First off, & shouldn't be in the URL that comes to your server. If it is, someone is likely double-encoding something.

第二,您不希望使用中间件对URL进行解码,除非仅在该中间件中使用了解码后的数据.我的意思是说您不应修改原始URL,否则其他中间件可能会感到困惑.

Second, you wouldn't want to decode the URL with middleware unless the usage of that decoded data is only used in that middleware. What I mean to say is that you shouldn't modify the original URL, or other middlware may get confused.

最后,JavaScript内置了decodeURIComponent(). https://developer.mozilla.org/zh-CN /docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent

Finally, JavaScript has decodeURIComponent() built-in. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent

这篇关于解码和从所有传入的请求到我的节点js应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆