libracore / erpnextswiss

ERPNext application for Switzerland-specific use cases
GNU Affero General Public License v3.0
74 stars 63 forks source link

Fix: Prevent JS error when entering an invalid postal code #119

Closed martinzoller closed 1 year ago

martinzoller commented 1 year ago

A little fix to a bug I just found. When creating a new address and entering an invalid postal code, the search function returns an empty array, i.e. response.message is defined but response.message[0] is not. The function will then encounter an error on line 145 when it tries to access response.message[0].city. We can avoid this case by checking that the array is non-empty.