// at the beginning
Posted by Michał ‘mina86’ Nazarewicz on 4th of December 2022
Just a quick message to remained/inform everyone that relative URLs can start with a double slash and that it means something different than a single slash at the beginning. Specifically, such relative addresses are resolved by taking schema of the website they are on (and keeping everything else as is).
For example, code for the link to my repositories in the site’s header is
<a href="//github.com/mina86">Code</a>. Since this page uses
https schema, browsers will navigate to
https://github.com/mina86 if the link is activated.
This may save you some typing but more importantly, if you’re developing a URL parsing code or a crawler make sure that it handles this case correctly.