fix($location): don't call `indexOf()` of undefined `href` attribute

Closes #7721