Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE9 cannot parse current url correctly #86

Open
chunminglu opened this issue Jan 4, 2016 · 3 comments
Open

IE9 cannot parse current url correctly #86

chunminglu opened this issue Jan 4, 2016 · 3 comments

Comments

@chunminglu
Copy link

Hello, my current url has pathname, and therefore like this format:
"http://localhost/pathname/"

And after pagination it should look like this:
"http://localhost/pathname/?page=2"

However after pushState function, the url becomes this:
"http://localhost/pathname/#/pathname/?page=2"

To figure out where causes the problem, I have a look at the source code, and find that in changeState function, there is a line like this:

// if current url not equal new url
        if (urlObject._relative !== parseURL()._relative) {

Instead of getting current url, however, parseURL() gets the base url, and therefore causes the problem. I fill in current url to parseURL, and then all functionality works fine.

I'm not sure if this modification will break other functions. Could you please have a look at this and see if there is another way to solve this problem without modifying the library's source code? Thanks very much.

@devote
Copy link
Owner

devote commented Jan 4, 2016

Hi!
You can configure the library:

window.history.redirect('/', '/pathname/');

@chunminglu
Copy link
Author

Thanks, now current url is correct.

But my function is still not working because in this block:

        if (urlObject._relative !== parseURL()._relative) {
            // if empty lastURLValue to skip hash change event
            lastURL = lastURLValue;
            if (replace) {
                // only replace hash, not store to history
                windowLocation.replace("#" + urlObject._special);
            } else {
                // change hash and add new record to history
                windowLocation.hash = urlObject._special;
            }
        }

it compares urlObject._relative ("/?page=2" when debugging) with parseURL()._relative ("/" when debugging). So it goes into the if clause and finally change hash to "/?page=2" and therefore the url becomes "http://localhost/pathname/#/?page=2". I want the url to be "http://localhost/pathname/?page=2" to work properly. Is there a way to not get into this if block?

@hanweifish
Copy link

Hi, which is the right way to configure the library
like:
window.history.redirect('/', '/pathname/');

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants