Skip to content

Commit

Permalink
Fix: use direct comparison instead of strings.Contains to filter laye…
Browse files Browse the repository at this point in the history
…rnames
  • Loading branch information
KoduIsGreat authored and ARolek committed Jul 1, 2024
1 parent c5bb076 commit c7296fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion atlas/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (m Map) FilterLayersByName(names ...string) Map {
nameStr := strings.Join(names, ",")
for i := range m.Layers {
// if we have a name set, use it for the lookup
if m.Layers[i].Name != "" && strings.Contains(nameStr, m.Layers[i].Name) {
if m.Layers[i].Name != "" && nameStr == m.Layers[i].Name {
layers = append(layers, m.Layers[i])
continue
} else if m.Layers[i].ProviderLayerName != "" && strings.Contains(nameStr, m.Layers[i].ProviderLayerName) { // default to using the ProviderLayerName for the lookup
Expand Down
20 changes: 20 additions & 0 deletions atlas/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@ func TestMapFilterLayersByName(t *testing.T) {
},
},
},
{
grid: atlas.Map{
Layers: []atlas.Layer{
{
Name: "layer1",
},
{
Name: "layer1roads",
},
},
},
name: "layer1roads",
expected: atlas.Map{
Layers: []atlas.Layer{
{
Name: "layer1roads",
},
},
},
},
}

for i, tc := range testcases {
Expand Down

0 comments on commit c7296fd

Please sign in to comment.