Merge pull request #3959 from overleaf/jpa-take-note-of-past-url

[UnsupportedBrowserMiddleware] take note of the past URL in redirect

GitOrigin-RevId: d80ed876f87e54c181f00669a11795a2ce44e5a5
This commit is contained in:
Jakob Ackermann
2021-04-29 02:09:33 +00:00
committed by Copybot
parent cf496e1fd2
commit 23c73b9bf1
4 changed files with 78 additions and 7 deletions
@@ -44,9 +44,10 @@ describe('UnsupportedBrowsers', function () {
})
it('redirects unsupported browsers to unsupported page', function (done) {
const url = '/project'
this.user.request(
{
url: '/project',
url,
headers: {
// IE11 user agent
'user-agent':
@@ -56,7 +57,52 @@ describe('UnsupportedBrowsers', function () {
(error, response) => {
expect(error).to.not.exist
expect(response.statusCode).to.equal(302)
expect(response.headers.location).to.equal('/unsupported-browser')
expect(response.headers.location).to.equal(
'/unsupported-browser?fromURL=' + encodeURIComponent(url)
)
done()
}
)
})
it('shows the previous URL', function (done) {
const url = '/project/60867f47174dfd13f1e00000'
this.user.request(
{
url: '/unsupported-browser?fromURL=' + encodeURIComponent(url),
headers: {
// IE11 user agent
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
},
},
(error, response, body) => {
expect(error).to.not.exist
expect(response.statusCode).to.equal(200)
expect(body).to.include('URL:')
expect(body).to.include(url)
done()
}
)
})
it('shows a sanitized URL', function (done) {
const url = 'https://evil.com/the/pathname'
this.user.request(
{
url: '/unsupported-browser?fromURL=' + encodeURIComponent(url),
headers: {
// IE11 user agent
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
},
},
(error, response, body) => {
expect(error).to.not.exist
expect(response.statusCode).to.equal(200)
expect(body).to.include('URL:')
expect(body).to.not.include('evil.com')
expect(body).to.include('/the/pathname')
done()
}
)