Fixes one option trie case

This commit is contained in:
Mouse Reeve 2022-01-10 16:53:30 -08:00
parent f6d6285009
commit 4202498442

View file

@ -58,15 +58,17 @@
function searchTrie(trie) { function searchTrie(trie) {
const options = Object.values(trie); const options = Object.values(trie);
if (!options.length) { if (typeof trie == 'string') {
return; return [trie];
} else if (typeof options[0] == 'string') {
return [options[0]];
} }
return options.map(option => { return options.map(option => {
const newTrie = option; const newTrie = option;
if (typeof newTrie == 'string') {
return [newTrie];
}
return searchTrie(newTrie); return searchTrie(newTrie);
}).reduce((prev, next) => prev.concat(next)); }).reduce((prev, next) => prev.concat(next));
} }
@ -79,13 +81,32 @@
})(); })();
const mimetypeTrie = { const mimetypeTrie = {
"a": {
"a": {
"c": "AAC",
},
"z": {
"w": "AZW",
}
},
"d": "Daisy",
"e": "ePub",
"f": "FLAC",
"h": "HTML",
"m": {
"4": {
"a": "M4A",
"b": "M4B",
},
"o": "MOBI",
"p": "MP3",
},
"o": "OGG",
"p": { "p": {
"d": { "d": {
"f": "PDF", "f": "PDF",
}, },
"n": { "l": "Plaintext",
"g": "PNG",
},
}, },
}; };