Repository: favonia/cloudflare-ddns
Pull request #809 (2024-07-17 20:33:02)

fix(domain): fix incorrect parsing of *.*.foo.bar

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/809?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 93.92%. Comparing base [(`1404d0f`)](https://app.codecov.io/gh/favonia/cloudflare-ddns/commit/1404d0f016c25317b90813934fca7c6a5861b0fc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) to head [(`3fc66ad`)](https://app.codecov.io/gh/favonia/cloudflare-ddns/commit/3fc66ad37050c2b14415be4eda5ca59b663adf81?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main     #809   +/-   ##
=======================================
  Coverage   93.92%   93.92%           
=======================================
  Files          50       50           
  Lines        2157     2157           
=======================================
  Hits         2026     2026           
  Misses        120      120           
  Partials       11       11           
```

| [Flag](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/809/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/809/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia) | `93.92% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/favonia/cloudflare-ddns/pull/809?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=favonia).


Patch:
diff --git a/internal/domain/domain.go b/internal/domain/domain.go
index a22253a..47fa32e 100644
--- a/internal/domain/domain.go
+++ b/internal/domain/domain.go
@@ -68,7 +68,7 @@ func New(domain string) (Domain, error) {
 	// Special case 2: "*.something"
 	if normalized, ok := strings.CutPrefix(normalized, "*."); ok {
 		// redo the normalization after removing the offending "*" to get the true error (if any)
-		normalized, err := profileKeepingLeadingDots.ToASCII(strings.TrimPrefix(normalized, "*."))
+		normalized, err := profileKeepingLeadingDots.ToASCII(normalized)
 		return Wildcard(normalized), err
 	}
 


Test patch:
diff --git a/internal/domain/domain_test.go b/internal/domain/domain_test.go
index e5c10d1..cc96955 100644
--- a/internal/domain/domain_test.go
+++ b/internal/domain/domain_test.go
@@ -97,6 +97,7 @@ func TestNew(t *testing.T) {
 		{"*...｡..a.com", w(".....a.com"), true, ""},
 		{"*......", w(""), true, ""},
 		{"*｡｡｡｡｡｡", w(""), true, ""},
+		{"*.*.*", w("*.*"), false, `idna: disallowed rune U+002A`},
 	} {
 		t.Run(tc.input, func(t *testing.T) {
 			t.Parallel()