Improve escaping HTML entities in URL

Prevents unwanted double encoding of URLs.

related #229