Modify the ZIM backend, so that findTitlesWithPrefix only returns articles.

And not other types of contents (javascript etc).
Fixes #151
This commit is contained in:
mossroy 2016-01-08 17:07:53 +01:00
parent 21ce7b14d3
commit fb21691f5e

View File

@ -119,7 +119,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
var that = this;
util.binarySearch(0, this._file.articleCount, function(i) {
return that._file.dirEntryByTitleIndex(i).then(function(dirEntry) {
if (dirEntry.title == "")
if (dirEntry.title === "")
return -1; // ZIM sorts empty titles (assets) to the end
else if (dirEntry.namespace < "A")
return 1;
@ -133,7 +133,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
if (index >= firstIndex + resultSize || index >= that._file.articleCount)
return titles;
return that._file.dirEntryByTitleIndex(index).then(function(dirEntry) {
if (dirEntry.title.slice(0, prefix.length) == prefix)
if (dirEntry.title.slice(0, prefix.length) === prefix && dirEntry.namespace === "A")
titles.push(that._dirEntryToTitleObject(dirEntry));
return addTitles(index + 1);
});