Unshorten Google Links Challenge

Given a valid goo.gl shortened link, output the original URL.

Example

goo.gl/qIwi3N would give something like https://codegolf.stackexchange.com/. For input, you can choose to have the https?:// at the beginning, you can choose to have www. before the goo.gl, and you can also choose to get rid of the goo.gl if you only want the end of the URL. A slash at the end is optional for input and output. So, your input will end up matching the regex (https?://)?(www\.)?(goo\.gl/)?[A-Za-z0-9]+/?. For the output, you can choose whether or not to output https?://, whether or not to output www., and whether or not to output a trailing slash. However, you must be consistent with your I/O formatting.

I will say that you do not have to be consistent with https vs. http for output (but you must be consistent for input), as long as you are consistent with whether or not you include the whole https?:// part.

Test Cases

These are written with no https://, no www., no trailing slash in the input; yes https://, no www., and yes trailing slash in the output.

input -&gt; output
goo.gl/HaE8Au -&gt; https://codegolf.stackexchange.com/
goo.gl/IfZMwe -&gt; https://stackoverflow.com/
goo.gl/JUdmxL -&gt; https://chat.stackexchange.com/rooms/240/the-nineteenth-byte


Assumptions


You may assume that the shortened link will not point to another shortened link and that the destination site will return a status code of 2xx or 4xx (no redirections).


You can go here and enter a URL to apply the inverse operation of this: https://goo.gl/
CJam, 7 bytes

lg'"/5=


Test run

$ alias cjam
alias cjam='java -jar ~/.local/share/cjam-0.6.5.jar'
$ cjam unshorten.cjam &lt;&lt;&lt; goo.gl/HaE8Au; echo
https://codegolf.stackexchange.com/
$ cjam unshorten.cjam &lt;&lt;&lt; goo.gl/IfZMwe; echo
https://stackoverflow.com/
$ cjam unshorten.cjam &lt;&lt;&lt; goo.gl/JUdmxL; echo
https://chat.stackexchange.com/rooms/240/the-nineteenth-byte


How it works

lg reads a line from STDIN and makes a GET request to that URL. The shortened URL issues a 301 redirect, which CJam doesn't follow. For the first test case, this pushes

&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Moved Permanently&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY BGCOLOR="#FFFFFF" TEXT="#000000"&gt;
&lt;H1&gt;Moved Permanently&lt;/H1&gt;
The document has moved &lt;A HREF="https://codegolf.stackexchange.com/"&gt;here&lt;/A&gt;.
&lt;/BODY&gt;
&lt;/HTML&gt;


on the stack. Finally, '"/ splits at double quotes, and 5= gets the sixth chunk. Output is implicit.