From 6327a0ba12ad18e5a8853393cdc6b1fd58c7e7f8 Mon Sep 17 00:00:00 2001 From: SilverFox Date: Thu, 28 Sep 2017 05:48:52 +0800 Subject: [PATCH] Make add-base-url compatible with minified html --- pkg/nginx/template/template.go | 8 ++++---- pkg/nginx/template/template_test.go | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/nginx/template/template.go b/pkg/nginx/template/template.go index 5469000a7..c22625333 100644 --- a/pkg/nginx/template/template.go +++ b/pkg/nginx/template/template.go @@ -324,12 +324,12 @@ func buildProxyPass(host string, b interface{}, loc interface{}) string { // path has a slash suffix, so that it can be connected with baseuri directly bPath := fmt.Sprintf("%s%s", path, "$baseuri") if len(location.Rewrite.BaseURLScheme) > 0 { - abu = fmt.Sprintf(`subs_filter '' '' r; - subs_filter '' '' r; + abu = fmt.Sprintf(`subs_filter '' '' r; + subs_filter '' '' r; `, location.Rewrite.BaseURLScheme, bPath, location.Rewrite.BaseURLScheme, bPath) } else { - abu = fmt.Sprintf(`subs_filter '' '' r; - subs_filter '' '' r; + abu = fmt.Sprintf(`subs_filter '' '' r; + subs_filter '' '' r; `, bPath, bPath) } } diff --git a/pkg/nginx/template/template_test.go b/pkg/nginx/template/template_test.go index cecc69b9a..97b2925c2 100644 --- a/pkg/nginx/template/template_test.go +++ b/pkg/nginx/template/template_test.go @@ -64,34 +64,34 @@ var ( "redirect / to /jenkins and rewrite": {"/", "/jenkins", "~* /", ` rewrite /(.*) /jenkins/$1 break; proxy_pass http://upstream-name; - subs_filter '' '' r; - subs_filter '' '' r; + subs_filter '' '' r; + subs_filter '' '' r; `, true, ""}, "redirect /something to / and rewrite": {"/something", "/", `~* ^/something\/?(?.*)`, ` rewrite /something/(.*) /$1 break; rewrite /something / break; proxy_pass http://upstream-name; - subs_filter '' '' r; - subs_filter '' '' r; + subs_filter '' '' r; + subs_filter '' '' r; `, true, ""}, "redirect /end-with-slash/ to /not-root and rewrite": {"/end-with-slash/", "/not-root", `~* ^/end-with-slash/(?.*)`, ` rewrite /end-with-slash/(.*) /not-root/$1 break; proxy_pass http://upstream-name; - subs_filter '' '' r; - subs_filter '' '' r; + subs_filter '' '' r; + subs_filter '' '' r; `, true, ""}, "redirect /something-complex to /not-root and rewrite": {"/something-complex", "/not-root", `~* ^/something-complex\/?(?.*)`, ` rewrite /something-complex/(.*) /not-root/$1 break; proxy_pass http://upstream-name; - subs_filter '' '' r; - subs_filter '' '' r; + subs_filter '' '' r; + subs_filter '' '' r; `, true, ""}, "redirect /something to / and rewrite with specific scheme": {"/something", "/", `~* ^/something\/?(?.*)`, ` rewrite /something/(.*) /$1 break; rewrite /something / break; proxy_pass http://upstream-name; - subs_filter '' '' r; - subs_filter '' '' r; + subs_filter '' '' r; + subs_filter '' '' r; `, true, "http"}, } )