diff --git a/pkg/locodedb/calls.go b/pkg/locodedb/calls.go index d1c7e96..9cfafbb 100644 --- a/pkg/locodedb/calls.go +++ b/pkg/locodedb/calls.go @@ -24,7 +24,14 @@ func Get(locodeStr string) (Record, error) { return Record{}, err } - key, err := NewKey(locodeStr[:2], locodeStr[2:]) + country := locodeStr[:2] + location := locodeStr[2:] + + if len(locodeStr) == 6 { + location = locodeStr[3:] + } + + key, err := NewKey(country, location) if err != nil { return Record{}, err } diff --git a/pkg/locodedb/calls_test.go b/pkg/locodedb/calls_test.go index 0c5ac03..afc4a46 100644 --- a/pkg/locodedb/calls_test.go +++ b/pkg/locodedb/calls_test.go @@ -19,7 +19,7 @@ func TestGet(t *testing.T) { }) t.Run("locode", func(t *testing.T) { - rec, err := locodedb.Get("RUMOW") + rec, err := locodedb.Get("RU MOW") require.NoError(t, err) require.Equal(t, rec.Country, "Russia")