node url重定向
URL shorteners are a dime a dozen these days, and it is quite nice to have a pretty URL instead of a mile long string, but there are some downsides to URL shorteners: they can mask dangerous URLs and getting to the endpoint can be slow, since you end up making multiple requests. And what if a shortener sold out to a porn company?! Whoa!
如今,URL缩短器只是一角钱,拥有一个漂亮的URL而不是一英里长的字符串是一件很不错的事,但是URL缩短器有一些缺点:它们可以掩盖危险的URL,到达端点可能很慢,因为您最终提出了多个请求。 如果起酥油卖给了一家色情公司怎么办? 哇!
A while back I wrote a post about following URLs from command line with cURL. Since I love JavaScript and Node.js is in full flight, I want to show you linkfollower, a Node.js utility for following URL redirects and getting the final landing URL.
不久前,我写了一篇关于使用cURL从命令行跟踪URL的文章。 由于我喜欢JavaScript并且Node.js全面投入使用,因此我想向您展示linkfollower ,这是一个Node.js实用程序,用于跟踪URL重定向并获取最终的到达URL。
Start by installing linkfollower:
首先安装linkfollower :
yarn add linkfollower # or `npm install linkfollower`With linkfollower installed globally, we can use the follow command to follow the series of redirects until the final URL:
linkfollower安装了linkfollower ,我们可以使用follow命令跟随一系列重定向,直到最终到达URL:
# follow {url} follow http://davidwalsh.name/css # RESULT: # http://davidwalsh.name/css -> 301 # https://davidwalsh.name/css -> 301 # https://davidwalsh.name/css-animation-callback -> 200URL shorteners can be likened to a blindfold -- the promise of going one place but possible end up in another. Using linkfollower is a good practice if you care to be secure with links.
可以将URL缩短器比喻为蒙住眼睛-到达某个地方但可能最终落到另一个地方的承诺。 如果您想确保链接的安全性,那么使用linkfollower是一个好习惯。
翻译自: https://davidwalsh.name/follow-url-redirects-nodejs
node url重定向