Skip to content

Commit

Permalink
fix(UA): add failsafe if params not provided
Browse files Browse the repository at this point in the history
fix #166
  • Loading branch information
bobylito committed Mar 6, 2017
1 parent 20193b3 commit 30df97a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sources/hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var parseAlgoliaClientVersion = require('../common/parseAlgoliaClientVersion.js'
module.exports = function search(index, params) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion && algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params = params || {};
params.additionalUA = 'autocomplete.js ' + version;
}
return sourceFn;
Expand Down
1 change: 1 addition & 0 deletions src/sources/popularIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var parseAlgoliaClientVersion = require('../common/parseAlgoliaClientVersion.js'
module.exports = function popularIn(index, params, details, options) {
var algoliaVersion = parseAlgoliaClientVersion(index.as._ua);
if (algoliaVersion && algoliaVersion[0] >= 3 && algoliaVersion[1] > 20) {
params = params || {};
params.additionalUA = 'autocomplete.js ' + version;
}
if (!details.source) {
Expand Down
2 changes: 1 addition & 1 deletion test/playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h4>Multi-sections auto-complete</h4>

autocomplete('#contacts, #contacts1', { debug: true, hint: false, templates: { empty: 'empty' }, autoselect: true, appendTo: 'body' }, [
{
source: autocomplete.sources.hits(index, { hitsPerPage: 5 }),
source: autocomplete.sources.hits(index),
displayKey: 'name',
templates: {
footer: function(o, content) {
Expand Down

0 comments on commit 30df97a

Please sign in to comment.