From 9524d307eb481d7169f48e071bdc02124fca9c37 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sun, 6 Apr 2025 13:58:18 +0100 Subject: [PATCH] aliases: Add more tests for multiple suffix separators This patch adds more tests for situations involving multiple suffix separators. --- internal/aliases/aliases_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/aliases/aliases_test.go b/internal/aliases/aliases_test.go index 5d62aca..f8cf121 100644 --- a/internal/aliases/aliases_test.go +++ b/internal/aliases/aliases_test.go @@ -366,6 +366,22 @@ func TestRemoveDropsAndSuffix(t *testing.T) { {"a.bc+blah@def", "abc@def"}, {"x.yz@def", "xyz@def"}, {"x.yz@d.ef", "xyz@d.ef"}, + + // Cases with tricky mixes of suffix separators, to make sure we + // handle them correctly. + {"ab-xy@def", "ab@def"}, // Normal. + {"ab-+xy@def", "ab@def"}, // The two together, in different order. + {"ab+-xy@def", "ab@def"}, + {"ab-@def", "ab@def"}, // Ending in a separator. + {"ab+@def", "ab@def"}, + {"ab-+@def", "ab@def"}, + {"ab-xy-z@def", "ab@def"}, // Multiple in different places. + {"ab+xy-z@def", "ab@def"}, + {"ab-xy+z@def", "ab@def"}, + {"ab--xy@def", "ab@def"}, // Repeated separators. + {"ab++xy@def", "ab@def"}, + {"ab+-xy@def", "ab@def"}, + {"ab-+xy@def", "ab@def"}, } for _, c := range cases { addr := resolver.RemoveDropsAndSuffix(c.addr)