I am trying to use an \href linking to a web URL including an HTML anchor pointer. Hence I am using a hash sign (#) in the URL. For example to link the page https://github.com/latex3/hyperref#bug-reports.
Here is a minimal example:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{https://github.com/latex3/hyperref#bug-reports}{link with hash that doesn't work}
\href{https://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Commands}{link with hash where it works}
\end{document}
The problem is that the hash sign gets replaced by the URL escape character %23 when the PDF is generated. If I click on the link in the PDF the browser will get the link in the following form:
https://github.com/latex3/hyperref%23bug-reports
But this leads to an 404-Error on GitHub.
If I replace the %23 with # in the address bar, the proper page can be loaded.
On other pages (for example wikibooks) links with URL-escaped # work (shown in the example above).
Is it possible to switch off url-escaping of the hash sign in links?
I am using pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020) on MacOS Catalina.

xurl? – Bernard Jul 29 '20 at 14:31#unescaped. Why not leave it unescaped in the github link? My understanding is that hyperref does some stuff behind the scenes so that you don't need to escape#in the first place. And in fact, with TeXLive 2020, both of your examples work fine, so it seems that you can choose whether to escape#or not. – Teepeemm Jul 29 '20 at 14:41hyperrefdoes some hard work to allow you not to escape the#and still work correctly, so in general I'd prefer the unescaped#over\#anyway. In my tests all viewers resolved both links from the MWE correctly (PDF compiled with pdfLaTeX on MikTeX, checked the links with TeXworks' built-in viewer, SumatraPDF, Adobe Reader and Firefox). – moewe Jul 29 '20 at 15:17%23problem. So I will edit it out of the quesion. – nnn Jul 30 '20 at 07:03hyperref's trickery won't work and where an unescaped#throws errors (if you are using\url/\hrefwithin the argument of another command for example). In those cases you can either escape the#or use a workaround like\urldef. – moewe Jul 30 '20 at 07:18#and%23work. I run up-to-date Apple devices and OSs here FWIW. None of the above issues happen for me now. – LaTeXereXeTaL Jan 04 '21 at 20:55