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

Fixes #6836