node url重定向_使用Node.js跟踪URL重定向

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 -> 200


URL 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重定向

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值