This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push: new 65579fc feat: allow host with underscore (#3165) 65579fc is described below commit 65579fc45b97b450185e9e6e30aaa596f5bee68e Author: 罗泽轩 <spacewander...@gmail.com> AuthorDate: Thu Dec 31 11:48:54 2020 +0800 feat: allow host with underscore (#3165) --- apisix/schema_def.lua | 2 +- t/admin/routes.t | 8 ++++---- t/config-center-yaml/route.t | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua index 322f289..4992ea9 100644 --- a/apisix/schema_def.lua +++ b/apisix/schema_def.lua @@ -37,7 +37,7 @@ local id_schema = { } } -local host_def_pat = "^\\*?[0-9a-zA-Z-.]+$" +local host_def_pat = "^\\*?[0-9a-zA-Z-._]+$" local host_def = { type = "string", pattern = host_def_pat, diff --git a/t/admin/routes.t b/t/admin/routes.t index 72b0dd4..7f51420 100644 --- a/t/admin/routes.t +++ b/t/admin/routes.t @@ -798,8 +798,8 @@ passed --- request GET /t --- error_code: 400 ---- response_body -{"error_msg":"invalid configuration: property \"host\" validation failed: failed to match pattern \"^\\\\*?[0-9a-zA-Z-.]+$\" with \"a.*.foo.com\""} +--- response_body_like +{"error_msg":"invalid configuration: property \\"host\\" validation failed: failed to match pattern .* --- no_error_log [error] @@ -831,8 +831,8 @@ GET /t --- request GET /t --- error_code: 400 ---- response_body -{"error_msg":"invalid configuration: property \"host\" validation failed: failed to match pattern \"^\\\\*?[0-9a-zA-Z-.]+$\" with \"*.a.*.foo.com\""} +--- response_body_like +{"error_msg":"invalid configuration: property \\"host\\" validation failed: failed to match pattern .* --- no_error_log [error] diff --git a/t/config-center-yaml/route.t b/t/config-center-yaml/route.t index 9c5e30c..55653a4 100644 --- a/t/config-center-yaml/route.t +++ b/t/config-center-yaml/route.t @@ -255,3 +255,29 @@ routes: --- request GET /hello --- error_code: 200 + + + +=== TEST 10: hosts with '_' is valid +--- yaml_config eval: $::yaml_config +--- apisix_yaml +routes: + - + id: 1 + uri: /hello + hosts: + - foo.com + - v1_test-api.com + upstream: + nodes: + "127.0.0.1:1980": 1 + type: roundrobin +#END +--- more_headers +host: v1_test-api.com +--- request +GET /hello +--- response_body +hello world +--- no_error_log +[error]