有没有什么简单的方法可以在没有任何额外数据(url参数,css '#‘等)的情况下获得URL路径段?
例如:
完整网址:http://example.com/panel/list
我想要获取的路径段:/panel/list
完整网址:http://example.com/panel/list?user=joe
我想要获取的路径段:/panel/list
完整网址:http://example.com/panel/list#header
我想要获取的路径段:/panel/list
以及不是我的URL路径段的任何其他数据组合
发布于 2017-03-11 16:43:40
我认为你可以使用req.baseUrl + req.path
。
对于完整的URL,请使用req.originalUrl。
发布于 2018-11-09 12:06:11
对于不带任何参数的完整url,您可以使用req.protocol + '://' + req.get('host') + req.baseUrl + req.path;
https://stackoverflow.com/questions/42735645
复制相似问题