Get Redirect URL with cURL
URL redirects can be glorious or annoying depending on which side of them you are on and which side you want to be on. Redirects are helpful for vanity URLs (useful in advertising) but sometimes they're annoying in that they could potentially break your code if you encounter a redirect you weren't anticipating.
The useful and amazing cURL command line utility allows you to fetch an address and return its final destination URL:
# "/css" doesn't exist but WordPress tries to find the closest match
# and then redirects to it ("/css-animation-callback")
curl -Ls -w %{url_effective} -o /dev/null https://davidwalsh.name/css
# Outputs: https://davidwalsh.name/css-animation-callback
The url_effective
variable is what we're after. The L
directive tells cURL to follow redirects, the s
directive tells cURL to be silent (i.e. not output the page contents). You provide the URL, cURL follows it to its endpoint -- easy!
![CSS Filters]()
CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...
![Create Namespaced Classes with MooTools]()
MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does. Many developers create their classes as globals which is generally frowned up. I mostly disagree with that stance, but each to their own. In any event...
![Create an Animated Sliding Button Using MooTools]()
Buttons (or links) are usually the elements on our sites that we want to draw a lot of attention to. Unfortunately many times they end up looking the most boring. You don't have to let that happen though! I recently found a...
![Firefox Marketplace Animated Buttons]()
The Firefox Marketplace is an incredibly attractive, easy to use hub that promises to make finding and promoting awesome HTML5-powered web applications easy and convenient. While I don't work directly on the Marketplace, I am privy to the codebase (and so...
Follow a URL using JavaScript: https://www.npmjs.com/package/linkfollower