Skip to content

Commit

Permalink
Fix list_contains (a.k.a. the ~= mapcss operator)
Browse files Browse the repository at this point in the history
The ~= operator also allows for whitespace around the values.
E.g. [a~=y] matches
- a=y
- a=x;y;z
- a=x; y; z
The latter wasn't working with the original implementation
  • Loading branch information
Famlam committed Sep 13, 2024
1 parent e9e265e commit c4ea622
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mapcss/mapcss_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def string_contains(subject, string):

def list_contains(subject, string):
if subject is not None and string is not None:
return string in subject and string in subject.split(";")
return string in subject and any(map(lambda s: s.strip() == string, subject.split(";")))

def at(asset_lat, asset_lon, lat, lon):
return asset_lat == lat and asset_lon == lon
Expand Down

0 comments on commit c4ea622

Please sign in to comment.