Notice that the “#” in the URL had to be escaped with a backslash. This should not be necessary. Note that the
\urlcommands themselves do not require this, so it should be possible to write a macro that also does not require escaping the “#”. Notice all the commented out code. These are all failing attempts to remedy the problem.