Skip to content

Commit

Permalink
Trim when checking if the input is what3words (#10)
Browse files Browse the repository at this point in the history
Co-authored-by: Georgi Dobrilov <[email protected]>
  • Loading branch information
gdobrilov and GeorgiDobrilov authored Oct 5, 2023
1 parent 20ea3c7 commit ee37952
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dist/js/experian-address-validation.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/ts/address-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ export default class AddressValidation {
// Regex that checks if the input is the format for a what3words search. Ex: ///a.b.c
const regex = /^\/{0,}(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+|[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3})$/;

if (regex.test(this.currentSearchTerm) && this.options.enableWhat3Words && this.what3WordCountries.indexOf(this.currentCountryCode) > -1) {
if (regex.test(this.currentSearchTerm.trim()) && this.options.enableWhat3Words && this.what3WordCountries.indexOf(this.currentCountryCode) > -1) {
this.isWhat3Words = true;
this.currentSearchTerm = this.currentSearchTerm.trim();
}
else {
this.isWhat3Words = false;
Expand Down

0 comments on commit ee37952

Please sign in to comment.