From 83a8cd2f535786a93063c4756c522ffb26b2bc00 Mon Sep 17 00:00:00 2001 From: Mirko Geissler Date: Tue, 9 Aug 2016 10:50:35 +0200 Subject: [PATCH 1/3] Allow hyphen in last host path part --- plugins/common/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common/functions b/plugins/common/functions index 2952ee25d..dad241b5a 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -1065,7 +1065,7 @@ strip_inline_comments() { is_valid_hostname() { declare desc="return 0 if argument is a valid hostname; else return 1" - local hostname_string="${1,,}"; local hostname_regex='^(([a-z0-9\*](-?[a-z0-9])*)\.)*[a-z0-9\*](-?[a-z0-9])+\.[a-z]{2,}$' + local hostname_string="${1,,}"; local hostname_regex='^(([a-z0-9\*](-?[a-z0-9])*)\.)+([a-z0-9\*](-?[a-z0-9])*)$' if [[ $hostname_string =~ $hostname_regex ]]; then return 0 else From 6f9662af50d225db30b5db6e69984842280956a3 Mon Sep 17 00:00:00 2001 From: Mirko Geissler Date: Thu, 11 Aug 2016 13:02:39 +0200 Subject: [PATCH 2/3] Allow multiple hyphens in domain names --- plugins/common/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common/functions b/plugins/common/functions index dad241b5a..d60357c71 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -1065,7 +1065,7 @@ strip_inline_comments() { is_valid_hostname() { declare desc="return 0 if argument is a valid hostname; else return 1" - local hostname_string="${1,,}"; local hostname_regex='^(([a-z0-9\*](-?[a-z0-9])*)\.)+([a-z0-9\*](-?[a-z0-9])*)$' + local hostname_string="${1,,}"; local hostname_regex='^([a-z0-9\-\*]+\.)*[a-z0-9\-\*]+$' if [[ $hostname_string =~ $hostname_regex ]]; then return 0 else From 36ee71cb0a9973d449f2343235c437ea1faa231f Mon Sep 17 00:00:00 2001 From: Mirko Geissler Date: Thu, 11 Aug 2016 16:32:22 +0200 Subject: [PATCH 3/3] Put hyphen at the end of group expression --- plugins/common/functions | 2 +- tests/unit/20_domains.bats | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/common/functions b/plugins/common/functions index d60357c71..32d8ad9ac 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -1065,7 +1065,7 @@ strip_inline_comments() { is_valid_hostname() { declare desc="return 0 if argument is a valid hostname; else return 1" - local hostname_string="${1,,}"; local hostname_regex='^([a-z0-9\-\*]+\.)*[a-z0-9\-\*]+$' + local hostname_string="${1,,}"; local hostname_regex='^([a-z0-9\*-]+\.)*[a-z0-9\*-]+$' if [[ $hostname_string =~ $hostname_regex ]]; then return 0 else diff --git a/tests/unit/20_domains.bats b/tests/unit/20_domains.bats index 173b36fc0..4a0216747 100644 --- a/tests/unit/20_domains.bats +++ b/tests/unit/20_domains.bats @@ -35,6 +35,10 @@ teardown() { echo "output: "$output echo "status: "$status assert_success + run dokku domains:add $TEST_APP a--domain.with--hyphens + echo "output: "$output + echo "status: "$status + assert_success } @test "(domains) domains:add (multiple)" {