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

Closes #7721
Closes #8681