From 27a65ba0f50529bfb0c72b7c9967b86bcd186e05 Mon Sep 17 00:00:00 2001 From: liam4 Date: Mon, 12 Jun 2017 09:40:21 -0300 Subject: Case-insensitive group matching --- src/playlist-utils.js | 23 ++++++++++++++++++----- todo.txt | 6 ++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/playlist-utils.js b/src/playlist-utils.js index f65e247..b0eb4f0 100644 --- a/src/playlist-utils.js +++ b/src/playlist-utils.js @@ -24,12 +24,25 @@ function filterPlaylistByPath(playlist, pathParts) { // function encounters an item in the group path that is not found, it logs // a warning message and returns the group found up to that point. - let cur = pathParts[0] + const titleMatch = (group, caseInsensitive = false) => { + let a = getGroupTitle(group) + let b = cur - const match = playlist.find(group => { - const title = getGroupTitle(group) - return title === cur || title === cur + '/' - }) + if (caseInsensitive) { + a = a.toLowerCase() + b = b.toLowerCase() + } + + return a === b + } + + const cur = pathParts[0] + + let match = playlist.find(g => titleMatch(g, false)) + + if (!match) { + match = playlist.find(g => titleMatch(g, true)) + } if (match) { if (pathParts.length > 1) { diff --git a/todo.txt b/todo.txt index 129805c..bbb23f2 100644 --- a/todo.txt +++ b/todo.txt @@ -122,3 +122,9 @@ TODO: Figure out how to attempt to avoid being forced to convert every file.. converting a 10MB MP3 into an 80MB WAV is never good, even if we're storing it as a tempfile! (Done!) + +TODO: Let playlist filter match things lowercase. '72 Minutes Of Fame' should + be matched if '72 Minutes of Fame' can't be! (However, it would also be + best to prioritize a case-sensitive match before a non-case-sensitive + one. Given the input 'FoObAR', prioritize 'FoObAR' over 'Foobar'.) + (Done!) -- cgit 1.3.0-6-gf8a5