Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
JozefVerhoef committed Jan 21, 2022
2 parents 8af1606 + 8b4560c commit c7eb773
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 44 deletions.
18 changes: 13 additions & 5 deletions assets/js/postcode-eu-autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@
const getAddress = function ()
{
const postcode = postcodeRegex.exec(postcodeField.val())[0].replace(/\s/g, ''),
houseNumber = houseNumberRegex.exec(houseNumberField.val())[0].trim(),
url = settings.dutchAddressLookup + postcode + '/' + encodeURIComponent(encodeURIComponent(houseNumber));
houseNumberAndAddition = houseNumberRegex.exec(houseNumberField.val())[0].trim(),
url = settings.dutchAddressLookup.replace('${postcode}', encodeURIComponent(postcode)).replace('${houseNumberAndAddition}', encodeURIComponent(houseNumberAndAddition));

resetHouseNumberSelect();
resetAddressFields(addressFields);
Expand Down Expand Up @@ -398,9 +398,17 @@

const getSuggestions = autocompleteInstance.getSuggestions;

autocompleteInstance.getSuggestions = function () {
arguments[1] = encodeURIComponent(arguments[1]); // Term needs double encoding because of autodecoding of superglobals.
getSuggestions.apply(this, arguments);
autocompleteInstance.getSuggestions = function (context, term, response) {
const url = this.options.autocompleteUrl.replace('${context}', encodeURIComponent(context)).replace('${term}', encodeURIComponent(term));
return this.xhrGet(url, response);
}

const getDetails = autocompleteInstance.getDetails;

autocompleteInstance.getDetails = function (addressId, response)
{
const url = this.options.addressDetailsUrl.replace('${context}', encodeURIComponent(addressId));
return this.xhrGet(url, response);
}

intlField[0].addEventListener('autocomplete-select', function (e) {
Expand Down
Loading

0 comments on commit c7eb773

Please sign in to comment.