Use `history.location` before `document.location`.

Changes from @devote. We need to look at `history.location` when it exists (for polyfilled browsers, as `document.location` will included a hash.