#4132·backbone

Unexpected page router navigate in Mozilla

Author: ghostCreated Apr 5, 2017Updated Jul 19, 2023
Labelsquestion

If there any German, Japanese etc. and any symbols like these in the url, getHash method returns incorrect result because of wrong encoding of this symbols in the Firefox browser, see window.location.href. And because of this navigate method is triggered.

Navigate method is triggered because we have different urls in checkUrl function in the var current = this.getFragment(); and in this.fragment values.

Example in Mozilla:

Result wich is returned by getFragment function: https://example.com/example?filterBy_city=%E5%A4%A7%E9%98%AA%2C%E5%AF%8C%E5%B1%B1%2C%E5%B2%A1%E5%B1%B1

this.fragment value: https://example.com/example?filterBy_city=大阪%2C富山%2C岡山

Example in Chrome

Result wich is returned by getFragment function: https://example.com/example?filterBy_city=大阪%2C富山%2C岡山

this.fragment value: https://example.com/example?filterBy_city=大阪%2C富山%2C岡山

I find the solution for it using decodeFragment in the getHash method: image Would it be safely to do it this way?