diff --git a/ingest/ledgerbackend/toml.go b/ingest/ledgerbackend/toml.go index 7c42bc11c8..edbb137b8e 100644 --- a/ingest/ledgerbackend/toml.go +++ b/ingest/ledgerbackend/toml.go @@ -558,7 +558,7 @@ func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) { for i, val := range params.HistoryArchiveURLs { name := fmt.Sprintf("HISTORY.h%d", i) c.HistoryEntries[c.tablePlaceholders.newPlaceholder(name)] = History{ - Get: fmt.Sprintf("curl -sf %s/{0} -o {1}", val), + Get: fmt.Sprintf("curl -sf %s/{0} -o {1}", strings.TrimSuffix(val, "/")), } } } diff --git a/ingest/ledgerbackend/toml_test.go b/ingest/ledgerbackend/toml_test.go index 476a2ea953..c5d40c77e3 100644 --- a/ingest/ledgerbackend/toml_test.go +++ b/ingest/ledgerbackend/toml_test.go @@ -395,6 +395,28 @@ func TestGenerateConfig(t *testing.T) { } } +func TestHistoryArchiveURLTrailingSlash(t *testing.T) { + httpPort := uint(8000) + peerPort := uint(8000) + logPath := "logPath" + + params := CaptiveCoreTomlParams{ + NetworkPassphrase: "Public Global Stellar Network ; September 2015", + HistoryArchiveURLs: []string{"http://localhost:1170/"}, + HTTPPort: &httpPort, + PeerPort: &peerPort, + LogPath: &logPath, + Strict: false, + } + + captiveCoreToml, err := NewCaptiveCoreToml(params) + assert.NoError(t, err) + assert.Len(t, captiveCoreToml.HistoryEntries, 1) + for _, entry := range captiveCoreToml.HistoryEntries { + assert.Equal(t, "curl -sf http://localhost:1170/{0} -o {1}", entry.Get) + } +} + func TestExternalStorageConfigUsesDatabaseToml(t *testing.T) { var err error var captiveCoreToml *CaptiveCoreToml