fix($location): dont throw while parsing invalid URLs

Fixes #6836 

Not a critical one but a patch is minimal and someone reported it, so why not...