Skip to content

Commit bc0fa3e

Browse files
authored
Merge pull request #1334 from sadiqkhoja/enketo-redirection-copy
Enketo redirection copy
2 parents 2d26126 + 50b4eb6 commit bc0fa3e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

main.nginx.conf

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ http {
4646
~^__Host-(session=.+)$ $1;
4747
}
4848

49+
map $args $qp_deliminator {
50+
~.+ "&";
51+
default "?";
52+
}
53+
54+
map $arg_st $redirect_non_single_prefix {
55+
~.+ "${is_args}${args}${qp_deliminator}single=false";
56+
default "/new${is_args}${args}";
57+
}
58+
59+
map $arg_st $redirect_single_prefix {
60+
~.+ "${is_args}${args}";
61+
default "/new${is_args}${args}${qp_deliminator}single=true";
62+
}
63+
4964
server {
5065
listen 8686;
5166
server_name localhost;
@@ -70,7 +85,9 @@ http {
7085
# Following are the locations that serve a Form and these are redirected to the frontend:
7186
location ~ "^/-/single/(?<enketoId>[a-zA-Z0-9]+)$" {
7287
# Form fill link, public
73-
return 301 "/f/$enketoId$is_args$args";
88+
# If 'st' query parameter is not present, redirect to protected route with single only
89+
# end-of-form behavior (/new?single=true)
90+
return 301 "/f/$enketoId$redirect_single_prefix";
7491
}
7592
location ~ "^/-/preview/(?<enketoId>[a-zA-Z0-9]+)$" {
7693
# preview link
@@ -81,7 +98,8 @@ http {
8198
# we don't want them to be redirected to central-frontend
8299
location ~ "^/-/(?!thanks$|connection$|login$|logout$|api$|preview$)(?<enketoId>[a-zA-Z0-9]+)$" {
83100
# Form fill link (non-public), or Draft
84-
return 301 "/f/$enketoId/new$is_args$args";
101+
# If 'st' query parameter is present, add ?single=false for public access
102+
return 301 "/f/$enketoId$redirect_non_single_prefix";
85103
}
86104
location = /-/single/check-submitted {
87105
alias ./dist/blank.html;

0 commit comments

Comments
 (0)