Improve URL escaping logic
It's more correct to just call raise than raise(e)