mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-13 21:53:43 +01:00
Merge pull request #1299 from sharelatex/spd-redirect-bypass-header
Add support for header to allow bypass of redirects GitOrigin-RevId: 2d40c51c23809c19f0a053093e8ee0719a0190e2
This commit is contained in:
committed by
sharelatex
parent
366dbbd54f
commit
b0b87a7b6e
@@ -11,6 +11,7 @@ module.exports = RedirectManager =
|
||||
|
||||
createRedirect: (target) ->
|
||||
(req, res, next) ->
|
||||
return next() if req.headers?['x-skip-redirects']?
|
||||
code = 302
|
||||
if typeof target is 'string'
|
||||
url = target
|
||||
|
||||
@@ -33,6 +33,12 @@ describe "RedirectUrls", ->
|
||||
it 'redirects with query params', (done) ->
|
||||
assertRedirect 'get', '/redirect/qs?foo=bar&baz[]=qux1&baz[]=qux2', 302, '/destination/qs?foo=bar&baz[]=qux1&baz[]=qux2', done
|
||||
|
||||
it "skips redirects if the 'skip-redirects' header is set", (done) ->
|
||||
request.get {url: '/redirect/one', headers: {'x-skip-redirects': 'true'}}, (error, response) ->
|
||||
should.not.exist error
|
||||
response.statusCode.should.equal 404
|
||||
done()
|
||||
|
||||
it 'redirects to /sign_in_to_v1 with authWithV1 setting', (done) ->
|
||||
assertRedirect(
|
||||
'get',
|
||||
|
||||
Reference in New Issue
Block a user