mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-09 04:06:27 -04:00
Adopt changes to getTitleOrUrl function from Kiwix JS
Former-commit-id: 99982d22209c3858c60a3e0ffe96ab60a88bee98 [formerly 7c6295f9a2643e4d8f6239e2059cd2de9b7e9d93] Former-commit-id: 80f68e9b16d27e4db6dd51eeacacb0ffdaf3ce60
This commit is contained in:
parent
92a8159709
commit
b74228ce03
@ -190,13 +190,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
|
|||||||
if (dirEntry.namespace < "A") return 1;
|
if (dirEntry.namespace < "A") return 1;
|
||||||
if (dirEntry.namespace > "A") return -1;
|
if (dirEntry.namespace > "A") return -1;
|
||||||
// We should now be in namespace A
|
// We should now be in namespace A
|
||||||
if (dirEntry.title) {
|
return prefix <= dirEntry.getTitleOrUrl() ? -1 : 1;
|
||||||
return prefix <= dirEntry.title ? -1 : 1;
|
|
||||||
} else {
|
|
||||||
// Some dirEntries (e.g. subtitles) have no title, but are still sorted in the A namespace,
|
|
||||||
// so, like libzim, we have to use the url as a comparator [kiwix-js #440 #443]
|
|
||||||
return prefix <= dirEntry.url ? -1 : 1;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, true).then(function(firstIndex) {
|
}, true).then(function(firstIndex) {
|
||||||
var dirEntries = [];
|
var dirEntries = [];
|
||||||
@ -207,7 +201,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
|
|||||||
'nextStart': index
|
'nextStart': index
|
||||||
};
|
};
|
||||||
return that._file.dirEntryByTitleIndex(index).then(function(dirEntry) {
|
return that._file.dirEntryByTitleIndex(index).then(function(dirEntry) {
|
||||||
var title = dirEntry.title ? dirEntry.title : dirEntry.url;
|
var title = dirEntry.getTitleOrUrl();
|
||||||
if ((saveStartIndex === null || !title.indexOf(prefix)) && dirEntry.namespace === "A")
|
if ((saveStartIndex === null || !title.indexOf(prefix)) && dirEntry.namespace === "A")
|
||||||
dirEntries.push(dirEntry);
|
dirEntries.push(dirEntry);
|
||||||
return addDirEntries(index + 1);
|
return addDirEntries(index + 1);
|
||||||
|
@ -108,7 +108,8 @@ define([], function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a getter function that returns the URL if the title is empty
|
* Defines a function that returns the URL if the title is empty, as per the specification
|
||||||
|
* See https://wiki.openzim.org/wiki/ZIM_file_format#Directory_Entries
|
||||||
*
|
*
|
||||||
* @returns {String} The dirEntry's title or, if empty, the dirEntry's (unescaped) URL
|
* @returns {String} The dirEntry's title or, if empty, the dirEntry's (unescaped) URL
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user