Palats / mapshot

Factorio mod to export maps as zoomable html
Apache License 2.0
77 stars 12 forks source link

Empty "tags" object #1

Closed nielsvanrijn closed 3 years ago

nielsvanrijn commented 3 years ago

On line 84 of index.html info.tags gets checked with an if(){} statement, in my case my tags object was empty like so

"tags":{}

The if(){} returns true because an empty JavaScript object is a truthy value. This causes the for loop on line 85 to throw an error because it can't iterate.

The fix (I think would be best) is to check for the length of keys in the object.

if (Object.keys(info.tags).length > 0) {
//
}
Palats commented 3 years ago

Thanks for the report! I'll probably submit a fix & release a new version later today. Also, it is probably a sign that the project grew enough to have more formal testing :)