From 4202498442e582f85c62e352219ad6ce8a33a753 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 10 Jan 2022 16:53:30 -0800 Subject: [PATCH] Fixes one option trie case --- bookwyrm/static/js/autocomplete.js | 35 ++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/bookwyrm/static/js/autocomplete.js b/bookwyrm/static/js/autocomplete.js index b9877b924..d2d66b4a6 100644 --- a/bookwyrm/static/js/autocomplete.js +++ b/bookwyrm/static/js/autocomplete.js @@ -58,15 +58,17 @@ function searchTrie(trie) { const options = Object.values(trie); - if (!options.length) { - return; - } else if (typeof options[0] == 'string') { - return [options[0]]; + if (typeof trie == 'string') { + return [trie]; } return options.map(option => { const newTrie = option; + if (typeof newTrie == 'string') { + return [newTrie]; + } + return searchTrie(newTrie); }).reduce((prev, next) => prev.concat(next)); } @@ -79,13 +81,32 @@ })(); 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": { "d": { "f": "PDF", }, - "n": { - "g": "PNG", - }, + "l": "Plaintext", }, };