history.js
history.js copied to clipboard
Trailing slash always appended to URL before state parameters
Hi,
The standard for our site is to remove trailing slashes in URLs with a permanent redirect. However, the History control seems to be always appending a slash before the state parameters. Shouldn't it just be looking at the current URL and appending the state parameters rather than always assuming a trailing slash?
Is there any way to control that behaviour?
Thanks,
Jason
Having the same problem. This broke my rails app routes because of the "unix" style paths
I ended up editing the js to stop it appending the trailing slash.
i tried that too, but ultimately ended up going w bbq.js because all i needed was the basics anyway. didnt really look too closely but maybe bbq can do all the stuff this does anyway. worth looking at if youre still having trouble.
I think I looked at bbq but it just uses the hash rather than querystring right?
Yep, I believe that was the difference.
If your page URL is http://example.com/page, try calling pushState() with a url like "page?parameter".
+1 @AntonKast - This is the solution, solved it for me.
+1 @AntonKast
@AntonKast the solution works, but we should get this changed so it doesn't keep adding it on. As @jasonhill said we should be able to control this currently doesn't mimic the history api
I agree with @AaronLayton
Any news on this issue?
When I use query to define new location it adds trailing slash which doesn't make sense. There could be an option to enable/disable this behavior.
What do you think?
+1
+1
+1
+1
+1
+1
I forgot to say that it only happens to me when domain is localhost.
This piece of code might be useful for some.
var href = $(this).prop("href");
History.pushState(null, null, href);
+1
@mhlavac :+1:
+1
2017 now passing...
2019 now passing...
Is this issue still a problem in 2019? Unless we are stuck supporting older, non-evergreen browsers etc.
Instead change the logic where trialling '/' is invalid
Ex. In case there is request parameters too - https://www.xxxx.xxx/customer/?city=delhi // This is invalid case where /? should not together Best suitable solution would be replace trialling slash with .replace(//$/, '')
Code : else if ( firstChar === '?' ) { // Query URL fullUrl = History.getPageUrl().replace(//$/, '').replace(/[?#].*/,'')+url; }
After change: https://www.xxxx.xxx/customer?city=delhi
I forgot to say that it only happens to me when domain is localhost.
Hi, did you find any workaround or solution for this? @MiguelRipoll23