Rudloff / openvegemap

Find vegetarian and vegan restaurants in your city
https://openvegemap.netlib.re/
GNU General Public License v3.0
72 stars 9 forks source link

Second-level domain issue for Website #102

Closed Mortein closed 2 years ago

Mortein commented 2 years ago

https://github.com/Rudloff/openvegemap/blob/0abd68fcc4ac5671512f5e40c012a3358eb751f6/js/popup.js#L123

The default call for extractDomain doesn't work so well with domain names that use second-level domains, or countries that use second-level domains (e.g. New Zealand, Australia, etc.). A restaurant such as Subway, using the New Zealand website https://www.subway.co.nz, appears as co.nz for the Website in the popup.

According to the extract-domain documentation, you can enable TLD support with extractDomain(this.tags.website, { tld: true }). It does have a slight performance impact, but for one call this would be less than 0.5 ms.

Alternatively, using regex to strip just the hostname from the URL would also work.

Rudloff commented 2 years ago

Thanks for the report. extractDomain() is only called when opening the pop-in, so the performance hit is acceptable, so I added this option.