xhr.responseURL for redirects
bblfish opened this issue · 3 comments
In order to be able to find out if a request was redirected to another URL one needs to use the responseURL
method on XMLHTTPRequest
s which I found defined in the whatwg xhr spec.
Currently the code I had to write which works, but is not nice, looks like this:
val redirectURL = xhr.asInstanceOf[js.Dynamic].responseURL.asInstanceOf[String]
You can test it in the browser by compiling and running the html
It may be useful to have a static implementation - though I think it should be done in a way to take account of many browsers returning an undefined value I suppose.
As expected the simple version did not work with Safari or older browsers. Using UndefOr helped as shown here
PR welcome.
Taking time for PR, as I need to get much more familiar with the ecosystem, before I can feel confident I am doing the right thing.