Skip to content

Commit 1094cb2

Browse files
committed
Fixed issue with filtering values containing ampersands, which would not display any results
1 parent fc48609 commit 1094cb2

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

dist/assets/js/plugins/storeLocator/jquery.storelocator.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@
881881

882882
if(typeof data[k] !== 'undefined') {
883883
for (var l = 0; l < filterTests.length; l++) {
884-
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, ''));
884+
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, ''));
885885
}
886886
}
887887

@@ -891,7 +891,7 @@
891891
}
892892
// Inclusive filtering
893893
else {
894-
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, '')))) {
894+
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, '')))) {
895895
filterTest = false;
896896
}
897897
}
@@ -2474,7 +2474,7 @@
24742474
if (!taxFilters[k]) {
24752475
taxFilters[k] = [];
24762476
}
2477-
taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, '') + '\\b)';
2477+
taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, '') + '\\b)';
24782478
}
24792479
}
24802480
}
@@ -2533,17 +2533,17 @@
25332533
$this.slideDown();
25342534
}
25352535

2536+
// Output page numbers if pagination setting is true
2537+
if (_this.settings.pagination === true) {
2538+
_this.paginationSetup(page);
2539+
}
2540+
25362541
// Handle no results
25372542
if (_this.isEmptyObject(locationset) || locationset[0].result === 'none') {
25382543
_this.emptyResult();
25392544
return;
25402545
}
25412546

2542-
// Output page numbers if pagination setting is true
2543-
if (_this.settings.pagination === true) {
2544-
_this.paginationSetup(page);
2545-
}
2546-
25472547
// Set up the modal window
25482548
_this.modalWindow();
25492549

dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/categories-example.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ <h1 class="bh-sl-title">Using Chipotle as an Example</h1>
5858
<input type="checkbox" name="category" value="Coffee"> Coffee
5959
</label>
6060
</li>
61+
<li>
62+
<label>
63+
<input type="checkbox" name="category" value="Something & Sons"> Something & Sons
64+
</label>
65+
</li>
6166
</ul>
6267

6368
<ul id="category-filters-container2" class="bh-sl-filters">

dist/data/locations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"name": "Chipotle Golden Valley",
6262
"lat": "44.983935",
6363
"lng": "-93.380542",
64-
"category": "Restaurant",
64+
"category": "Restaurant, Something & Sons",
6565
"address": "515 Winnetka Ave. N",
6666
"address2": "",
6767
"city": "Golden Valley",

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ filtering.
4040
* Added callbackAutoGeoSuccess callback that fires after the geolocation API returns a successful result.
4141
* Added callbackFormVals callback that fires after the form values have been processed from the form.
4242
* Fixed issue with featuredLocations setting where featured locations at far distances would trigger distance alert.
43+
* Fixed issue with filtering values containing ampersands, which would not display any results - updated filtering regex.
4344
* Fixed issue where HTML5 Geolocation was skipped when using the fullMapStartBlank setting.
45+
* Fixed issue with pagination page numbers displaying after no results via PR from [heldr88](https://github.com/heldr88)
4446
* Fixed issue with taxonomy filtering and autoGeocode setting where HTML Geocoding API would run on every filter change.
4547
* Swapped the default location data type to be JSON instead of XML.
4648

src/js/jquery.storelocator.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@
877877

878878
if(typeof data[k] !== 'undefined') {
879879
for (var l = 0; l < filterTests.length; l++) {
880-
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, ''));
880+
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, ''));
881881
}
882882
}
883883

@@ -887,7 +887,7 @@
887887
}
888888
// Inclusive filtering
889889
else {
890-
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, '')))) {
890+
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, '')))) {
891891
filterTest = false;
892892
}
893893
}
@@ -2470,7 +2470,7 @@
24702470
if (!taxFilters[k]) {
24712471
taxFilters[k] = [];
24722472
}
2473-
taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, '') + '\\b)';
2473+
taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\]|&\s+)/g, '') + '\\b)';
24742474
}
24752475
}
24762476
}
@@ -2539,7 +2539,7 @@
25392539
_this.emptyResult();
25402540
return;
25412541
}
2542-
2542+
25432543
// Set up the modal window
25442544
_this.modalWindow();
25452545

0 commit comments

Comments
 (0)