Bug 995873 - Don't use replaceState if it would result in an invalid URL
r=justdave, a=justdave