Fix Tag.matchesProperties and RegexTag.matchesProperties, they do match on definedProperties now (and are faster)

This commit is contained in:
Pieter Vander Vennet 2021-10-10 20:14:06 +02:00
parent 30bc620827
commit 15ff38a098
3 changed files with 51 additions and 21 deletions

View file

@ -47,6 +47,11 @@ export class RegexTag extends TagsFilter {
}
matchesProperties(tags: any): boolean {
if(typeof this.key === "string"){
const value = tags[this.key] ?? ""
return RegexTag.doesMatch(value, this.value) != this.invert;
}
for (const key in tags) {
if (key === undefined) {
continue;

View file

@ -23,26 +23,14 @@ export class Tag extends TagsFilter {
matchesProperties(properties: any): boolean {
for (const propertiesKey in properties) {
if (!properties.hasOwnProperty(propertiesKey)) {
continue
}
if (this.key === propertiesKey) {
const value = properties[propertiesKey];
if (value === undefined) {
continue
}
return value === this.value;
}
}
// The tag was not found
if (this.value === "") {
const foundValue = properties[this.key]
if (foundValue === undefined && (this.value === "" || this.value === undefined)) {
// The tag was not found
// and it shouldn't be found!
return true;
}
return false;
return foundValue === this.value;
}
asOverpass(): string[] {