File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -119,8 +119,11 @@ class XhrServer
119
119
# Returns a HTTP redirect. Used to test the redirection handling code.
120
120
@app .all ' /_/redirect/:status/:next_page' , (request , response ) =>
121
121
response .statusCode = parseInt (request .params .status )
122
- response .header ' Location' ,
123
- " http://#{ request .get (' host' )} /_/#{ request .params .next_page } "
122
+ if request .query .relative
123
+ url = " /#{ request .params .next_page } "
124
+ else
125
+ url = " http://#{ request .get (' host' )} /_/#{ request .params .next_page } "
126
+ response .header ' Location' , url
124
127
body = " <p>This is supposed to have a redirect link</p>"
125
128
response .header ' Content-Type' , ' text/html'
126
129
response .header ' Content-Length' , body .length .toString ()
Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ describe 'XMLHttpRequest', ->
19
19
done ()
20
20
@xhr .send ()
21
21
22
+ it ' resolves effective request uri for the next location' , (done ) ->
23
+ @xhr .open ' GET' , ' http://localhost:8912/_/redirect/302/method?relative=true'
24
+ @xhr .onload = =>
25
+ expect (@xhr ._url [' href' ]).to .match (/ http:\/\/ localhost:8912\/ method/ )
26
+ done ()
27
+ @xhr .send ()
28
+
22
29
it ' persists custom request headers across redirects' , (done ) ->
23
30
@xhr .open ' GET' , ' http://localhost:8912/_/redirect/302/headers'
24
31
@xhr .setRequestHeader ' X-Redirect-Test' , ' should be preserved'
You can’t perform that action at this time.
0 commit comments