开发者

any way of making encodeURIComponent in javascript ignore certain characters?

开发者 https://www.devze.com 2022-12-30 12:46 出处:网络
is there any way I can make the encodeURIComponentmethod ignore certain characters for example if I don\'t 开发者_Go百科want it to encode the £ sign. ?This is not possible without wrapping it yoursel

is there any way I can make the encodeURIComponent method ignore certain characters for example if I don't 开发者_Go百科want it to encode the £ sign. ?


This is not possible without wrapping it yourself.

Probably the safest thing to do would be...not do this. If you're a thrill seeker, just undo the parts you want decoded after the encoding is complete.

Something like this might be a naive way (i.e. my way) of doing it:

encodeURIComponent(uri).replace('%A3','£')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号