mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #932 from sharelatex/as-redirect-query-string
Support passing through query params in redirects
This commit is contained in:
commit
b16cffe587
3 changed files with 13 additions and 2 deletions
|
@ -23,4 +23,11 @@ module.exports = RedirectManager =
|
||||||
url = target.url
|
url = target.url
|
||||||
if target.baseUrl?
|
if target.baseUrl?
|
||||||
url = "#{target.baseUrl}#{url}"
|
url = "#{target.baseUrl}#{url}"
|
||||||
res.redirect code, url
|
res.redirect code, url + getQueryString(req)
|
||||||
|
|
||||||
|
# Naively get the query params string. Stringifying the req.query object may
|
||||||
|
# have differences between Express and Rails, so safer to just pass the raw
|
||||||
|
# string
|
||||||
|
getQueryString = (req) ->
|
||||||
|
qs = req.url.match(/\?.*$/)
|
||||||
|
if qs? then qs[0] else ""
|
||||||
|
|
|
@ -29,3 +29,6 @@ describe "RedirectUrls", ->
|
||||||
|
|
||||||
it 'proxy URLs with multiple support methods', (done) ->
|
it 'proxy URLs with multiple support methods', (done) ->
|
||||||
assertRedirect 'get', '/redirect/get_and_post', 302, '/destination/get_and_post', done
|
assertRedirect 'get', '/redirect/get_and_post', 302, '/destination/get_and_post', done
|
||||||
|
|
||||||
|
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
|
|
@ -125,4 +125,5 @@ module.exports =
|
||||||
},
|
},
|
||||||
'/redirect/params/:id': {
|
'/redirect/params/:id': {
|
||||||
url: (params) -> "/destination/#{params.id}/params"
|
url: (params) -> "/destination/#{params.id}/params"
|
||||||
}
|
},
|
||||||
|
'/redirect/qs': '/destination/qs'
|
||||||
|
|
Loading…
Reference in a new issue