fix($location): don't break on numeric path arguments

Fixes #7054

Not sure if we want to include this in the core but I can see that it can be convenient in some cases. And well, since it is 5 minutes fix I don't care this way or another so will let others weight on this one.