diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c120131..a589e3af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.8 (2017-05-06) + +- Fix shortenName overzealously removes suffixes #221 + ## 0.8.7 (2016-11-22) - Lowercase record names to make imports case-insensitive. Fixes #206 diff --git a/main.go b/main.go index 84e3594c..51c93177 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( ) var r53 *route53.Route53 -var version = "0.8.7" +var version = "0.8.8" // Main entry point for cli53 application func Main(args []string) int { diff --git a/util.go b/util.go index 6e48f95a..c046eeed 100644 --- a/util.go +++ b/util.go @@ -149,11 +149,8 @@ func waitForChange(change *route53.ChangeInfo) { func shortenName(name, origin string) string { if name == origin { return "@" - } else if strings.HasSuffix(name, origin) { - return name[0 : len(name)-len(origin)-1] - } else { - return name } + return strings.TrimSuffix(name, "."+origin) } var reQuotedValue = regexp.MustCompile(`"((?:\\"|[^"])*)"`) diff --git a/util_test.go b/util_test.go index 95414a10..a5a945c1 100644 --- a/util_test.go +++ b/util_test.go @@ -90,4 +90,5 @@ func TestShortenName(t *testing.T) { assert.Equal(t, "a", shortenName("a.example.com.", "example.com.")) assert.Equal(t, "a.", shortenName("a.", "example.com.")) assert.Equal(t, "a.b", shortenName("a.b.example.com.", "example.com.")) + assert.Equal(t, "fineexample.com.", shortenName("fineexample.com.", "example.com.")) }