Fix a bug when appending to URLs with an empty query