When clicking a link which triggers a redirect (302 or whatever), PJAX disregards it and pushed the state with the link's URL.
I think it should push, in the state, the URL as sent in the response's header "Location". Also, probably worth looking at that header to check if the URL is external and if it is, then don't try to do PJAX on it.
When clicking a link which triggers a redirect (302 or whatever), PJAX disregards it and pushed the state with the link's URL.
I think it should push, in the state, the URL as sent in the response's header "Location". Also, probably worth looking at that header to check if the URL is external and if it is, then don't try to do PJAX on it.
I've tried tackling this on my own and it's not quite possible.
There's no way to figure out if there was a redirect. The only way I found was to add a header in the response, from my server, stating the "final url".
I've tried tackling this on my own and it's not quite possible.
There's no way to figure out if there was a redirect. The only way I found was to add a header in the response, from my server, stating the "final url".
Looks like jquery-pjax looks for a special 'X-PJAX-URL' response header and then falls back to the request url. Turbolinks looks for a 'X-XHR-Redirected-To' response header which is set by the gem on the server side (Rails).
Would it be possible to make use of the response.responseUrl property where/when it's available?
This feature would be useful to me as well.
Looks like jquery-pjax looks for a special 'X-PJAX-URL' response header and then falls back to the request url. Turbolinks looks for a 'X-XHR-Redirected-To' response header which is set by the gem on the server side (Rails).
Would it be possible to make use of the `response.responseUrl` property where/when it's available?
I believe this feature is extremely crucial, but if it requires changes to the server breaks the "it just works" feature of this library.
While we're doing this, @MoOx would you like pjax to send a X-PJAX header to the server so that the server can detect a pjax request?
I believe this feature is extremely crucial, but if it requires changes to the server breaks the "it just works" feature of this library.
While we're doing this, @MoOx would you like pjax to send a X-PJAX header to the server so that the server can detect a pjax request?
Although it isn't supported by all browsers (most notably, IE), we should definitely check if it's available and use it if it is.
It looks like [XMLHttpRequest.responseURL](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL) reflects the final URL after redirects. I see it's already being used in [the tests](https://github.com/MoOx/pjax/blob/6491e3243787556664dc254dcc55b6af226b6786/tests/lib/request.js).
Although it isn't supported by all browsers (most notably, IE), we should definitely check if it's available and use it if it is.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
When clicking a link which triggers a redirect (302 or whatever), PJAX disregards it and pushed the state with the link's URL.
I think it should push, in the state, the URL as sent in the response's header "Location". Also, probably worth looking at that header to check if the URL is external and if it is, then don't try to do PJAX on it.
Oh yeah. Will also add this to the incoming tests. Thanks for the report.
I've planned to work on that this week.
I've tried tackling this on my own and it's not quite possible.
There's no way to figure out if there was a redirect. The only way I found was to add a header in the response, from my server, stating the "final url".
Hum... Do you check others implementations of pjax ? Like jquery-pjax or turbolinks ?
This feature would be useful to me as well.
Looks like jquery-pjax looks for a special 'X-PJAX-URL' response header and then falls back to the request url. Turbolinks looks for a 'X-XHR-Redirected-To' response header which is set by the gem on the server side (Rails).
Would it be possible to make use of the
response.responseUrlproperty where/when it's available?Not a bad idea. We should make this key customisable.
PR welcome :)
I believe this feature is extremely crucial, but if it requires changes to the server breaks the "it just works" feature of this library.
While we're doing this, @MoOx would you like pjax to send a X-PJAX header to the server so that the server can detect a pjax request?
Why not.
The X-PJAX header has been added by #80.
However, there is currently no implementation for checking a X-PJAX-URL header.
It looks like XMLHttpRequest.responseURL reflects the final URL after redirects. I see it's already being used in the tests.
Although it isn't supported by all browsers (most notably, IE), we should definitely check if it's available and use it if it is.