dojo / core

:rocket: Dojo 2 - language helpers and utilities.
http://dojo.io
Other
213 stars 62 forks source link

core/request : node provider only redirects URLs with protocol and host #278

Closed sebilasse closed 7 years ago

sebilasse commented 7 years ago

"redirects" : from looking at the code it seems that the node provider does not resolve the nativeResponse.headers.location against the baseUrl.

seen in the wild : If you come from https://stackoverflow.com/users{/userId} you are redirected to /users{/userId}{/userName} and that SHOULD resolve to

https://stackoverflow.com/users{/userId}{/userName} ...

same for //stackoverflow.com/whatever where it should keep the protocol ...

sebilasse commented 7 years ago

I am using

import * as URL from 'url';
/* ... */
const u = URL.parse(nativeResponse.headers.location);
const redirectUrl = (!u.host || !u.protocol) ?
    URL.resolve(response.url, nativeResponse.headers.location) : nativeResponse.headers.location;
rorticus commented 7 years ago

Fix for this in https://github.com/dojo/core/pull/261

sebilasse commented 7 years ago

@rorticus @dylans Thanks for fixing this. And (related to redirects) a feature request ;) : It could be useful to store the redirected URLs in an array in the options object. The options are returned as well and the user now knows the "URLs in beetween".

dylans commented 7 years ago

And (related to redirects) a feature request ;) : It could be useful to store the redirected URLs in an array in the options object. The options are returned as well and the user now knows the "URLs in beetween".

Please open a new issue for this and we'll consider how to address it, otherwise it will get lost in the noise of this issue. :)

rorticus commented 7 years ago

Fixed in #261