Allow preservation of trailing slashes on TLS redirects via annotation. (#7144)
* allow retaining a trailing slash in a TLS redirect via annotation. Signed-off-by: mamiller <mamiller@rosettastone.com> * requested changes * gofmt
This commit is contained in:
parent
f7cba2486c
commit
b3dfee6ada
6 changed files with 70 additions and 3 deletions
|
|
@ -147,9 +147,11 @@ function _M.rewrite(location_config)
|
|||
|
||||
if redirect_to_https(location_config) then
|
||||
local request_uri = ngx.var.request_uri
|
||||
-- do not append a trailing slash on redirects
|
||||
if string.sub(request_uri, -1) == "/" then
|
||||
request_uri = string.sub(request_uri, 1, -2)
|
||||
-- do not append a trailing slash on redirects unless enabled by annotations
|
||||
if location_config.preserve_trailing_slash == false then
|
||||
if string.byte(request_uri, -1, -1) == string.byte('/') then
|
||||
request_uri = string.sub(request_uri, 1, -2)
|
||||
end
|
||||
end
|
||||
|
||||
local uri = string_format("https://%s%s", redirect_host(), request_uri)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue