1 <!-- subject: {URLs} with <code>//</code> at the beginning -->
2 <!-- date: 2022-12-04 02:09:04 -->
3 <!-- tags: url, parsing, lazydevs -->
4 <!-- categories: Articles, Techblog -->
6 <p>A quick reminder that relative URLs can start with a double slash and
7 that this means something different than a single slash at the beginning.
8 Specifically, such relative addresses are resolved by taking the schema (and
9 only the schema) of the website they are on.
11 <p>For example, the code for the link to my repositories in the site’s header
13 href=
"//<wbr>github.com/<wbr>mina86"><wbr>Code
<wbr></a
></code>.
14 Since this page uses
<code>https
</code> schema, browsers will navigate
15 to
<code>https://github.com/mina86
</code> if the link is activated.
17 <p>This little trick can save you some typing, but more importantly, if you’re
18 developing a URL parsing code or a crawler, make sure that it handles this
19 case correctly. It may seem like a small detail, but it can have a lasting
20 impact on the functionality of your code.