diff options
author | liam4 <towerofnix@gmail.com> | 2017-06-12 09:40:21 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-06-12 09:40:21 -0300 |
commit | 27a65ba0f50529bfb0c72b7c9967b86bcd186e05 (patch) | |
tree | 82d26137c1b93b4ae867e17f9ddedb2a0f46ec44 /src | |
parent | bafe90fb6a0c7fcb911df537ef448bbbb9ecf457 (diff) |
Case-insensitive group matching
Diffstat (limited to 'src')
-rw-r--r-- | src/playlist-utils.js | 23 |
1 files changed, 18 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) { |