Open chunminglu opened 8 years ago
Hi! You can configure the library:
window.history.redirect('/', '/pathname/');
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?
Hi, which is the right way to configure the library like: window.history.redirect('/', '/pathname/');
Thanks
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:
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.