2727 return 200 'ok';
2828 }
2929
30- location ~ ^/(?<repo>[A-Za-z0-9\-_\.]+)(?<subpath>/.*)?$ {
30+ # NOTE: subpath is not currently used.
31+ location ~ ^/(?<repo>[A-Za-z0-9\-_\.]*)(?<subpath>/.*)?$ {
3132 # $https is set to 'on' when connecting to nginx via HTTPS directly.
3233 set $https_status $https;
3334 if ($http_x_forwarded_proto = 'https') {
@@ -105,8 +106,7 @@ data:
105106 server_name sigs.k8s.io sigs.kubernetes.io;
106107 listen 80;
107108
108- # The ?! block is negative-lookahead to prevent `/repo/` from grouping into (`repo`, `/`) while `/repo/path` will still group as (`repo`, `/path`).
109- location ~ ^/(?<sig_repo>[A-Za-z0-9\-_\.]+)(?!/+$)(?<repo_subpath>/.*)?$ {
109+ location ~ ^/(?<sig_repo>[A-Za-z0-9\-_\.]*)(?<repo_subpath>/.*)?$ {
110110 # $https is set to 'on' when connecting to nginx via HTTPS directly.
111111 set $https_status $https;
112112 if ($http_x_forwarded_proto = 'https') {
@@ -133,10 +133,19 @@ data:
133133 ';
134134 }
135135
136+ # nginx config syntax doesn't have an OR operator.
137+ set $repo_root 0;
138+ if ($repo_subpath = "/") {
139+ set $repo_root 1;
140+ }
136141 if ($repo_subpath = "") {
142+ set $repo_root 1;
143+ }
144+ if ($repo_root) {
137145 # This is a regular request for https://sigs.k8s.io/<repo>
138- # Redirect to repo landing page.
139- return 301 https://github.com/kubernetes-sigs/$sig_repo;
146+ # Redirect to repo landing page, retain the trailing slash if
147+ # present.
148+ return 301 https://github.com/kubernetes-sigs/$sig_repo$repo_subpath;
140149 }
141150
142151 # Default to redirecting to files in the tree.
0 commit comments