The issue is the the final bracket is not included as part of the URL. The
obvious comment at this point would be "just encode it", but I was curious what
the standard says. RFC 3986 (2005) lists these characters under "gen-delims":
If data for a URI component would conflict with a reserved character's purpose
as a delimiter, then the conflicting data must be percent-encoded before the
URI is formed.
So its not possible for square brackets in a fragment to conflict, hence they do
not need to be percent encoded. Note that the GitHub MarkDown parser handles
this:
This code:
Produces this (newline added for readability):
The issue is the the final bracket is not included as part of the URL. The obvious comment at this point would be "just encode it", but I was curious what the standard says. RFC 3986 (2005) lists these characters under "gen-delims":
which become part of "reserved":
This part of the spec is important:
https://tools.ietf.org/html/rfc3986#section-2.2
So the question is, does
]
in the fragment conflict with its purpose as a delimiter? Brackets are only used as part of an IP-literal:https://tools.ietf.org/html/rfc3986#section-3.2.2
Example:
https://stackoverflow.com/questions/40189084/-/46711717
So its not possible for square brackets in a fragment to conflict, hence they do not need to be percent encoded. Note that the GitHub MarkDown parser handles this:
http://nim-lang.github.io/Nim/system#echo,varargs[typed,]