URL在NodeJs中编码string
在PHP中我们有:
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
什么是urlencode();
的NodeJs版本urlencode();
你需要吗? urlendcode
在这种情况下,可能与nodejs无关,在客户端只使用javacript函数encodeURIComponent进行编码
例如:
var apiUrl: string = 'mycgi?foo='; apiUrl += encodeURIComponent(userInput)