Skip to content

Commit 7114a06

Browse files
authored
Exclude non-submission enketo endpoints from redirecting (#1022)
1 parent 1d7a7f9 commit 7114a06

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

files/nginx/odk.conf.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ server {
9999
# preview link
100100
return 301 "/f/$enketoId/preview$is_args$args";
101101
}
102-
location ~ "^/-/(?!thanks$)(?!connection$)(?<enketoId>[a-zA-Z0-9]+)$" {
102+
# The negative look ahead patterns in the following regex are for the Enketo endpoints which are
103+
# similar to the new submission endpoint i.e. /-/:enketoId but these are not enketoId, therefore
104+
# we don't want them to be redirected to central-frontend
105+
location ~ "^/-/(?!thanks$|connection$|login$|logout$|api$|preview$)(?<enketoId>[a-zA-Z0-9]+)$" {
103106
# Form fill link (non-public), or Draft
104107
return 301 "/f/$enketoId/new$is_args$args";
105108
}

test/nginx/test-nginx.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ describe('nginx config', () => {
213213
{ description: 'new or draft submission',
214214
request: `/-/${enketoId}`,
215215
expected: `f/${enketoId}/new` },
216+
217+
{ description: 'new submission - enketoId starts with thanks',
218+
request: `/-/thanksokay`,
219+
expected: `f/thanksokay/new` },
220+
221+
{ description: 'new submission - enketoId ends with thanks',
222+
request: `/-/okaythanks`,
223+
expected: `f/okaythanks/new` },
224+
225+
{ description: 'new submission - enketoId contains thanks',
226+
request: `/-/okaythanksokay`,
227+
expected: `f/okaythanksokay/new` },
216228
];
217229
enketoRedirectTestData.forEach(t => {
218230
it('should redirect old enketo links to central-frontend; ' + t.description, async () => {
@@ -230,6 +242,10 @@ describe('nginx config', () => {
230242
[
231243
'/-/thanks',
232244
'/-/connection',
245+
'/-/login',
246+
'/-/logout',
247+
'/-/api',
248+
'/-/preview',
233249
].forEach(request => {
234250
it(`should not redirect ${request} to central-frontend`, async () => {
235251
// when

0 commit comments

Comments
 (0)