Skip to content

Commit

Permalink
Fix newline handling of automatic ICANN updater
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-friedberger committed Aug 9, 2024
1 parent ef9b4e5 commit 8d21173
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tools/newgtlds.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,12 @@ func process(datFile *datFile, dataURL string, clk clock) (string, error) {
if err := renderData(&newDataBuf, entries); err != nil {
return "", err
}
newDataBufString := strings.TrimSuffix(newDataBuf.String(), "\n")

// If the newly rendered data doesn't match the existing data then we want to
// update the dat file content by replacing the old span with the new content.
if newDataBuf.String() != existingData {
newContent := newHeaderBuf.String() + "\n" + newDataBuf.String()
if newDataBufString != existingData {
newContent := newHeaderBuf.String() + "\n" + newDataBufString
if err := datFile.ReplaceGTLDContent(newContent); err != nil {
return "", err
}
Expand Down
2 changes: 0 additions & 2 deletions tools/newgtlds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ func TestProcess(t *testing.T) {
// https://www.iana.org/domains/root/db/aaa.html
aaa
// ===END ICANN DOMAINS===
...
Expand Down Expand Up @@ -738,7 +737,6 @@ aaa
// https://www.iana.org/domains/root/db/accountants.html
accountants
// ===END ICANN DOMAINS===
...
Expand Down

0 comments on commit 8d21173

Please sign in to comment.