« get me outta code hell

Remove extension from found track names in crawl-local - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2017-08-04 23:01:31 -0300
committerFlorrie <towerofnix@gmail.com>2017-08-04 23:01:37 -0300
commit2df2b68db50b363f37ab715199e43720f9345dd1 (patch)
treea2e9029993a91c65d333fa62a71f67cf1f4eb895
parent3dd9d4c40e3b81beebbe7c0a66df93e226ac0bd1 (diff)
Remove extension from found track names in crawl-local
-rwxr-xr-xsrc/crawl-local.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/crawl-local.js b/src/crawl-local.js
index 134a574..202c732 100755
--- a/src/crawl-local.js
+++ b/src/crawl-local.js
@@ -33,7 +33,12 @@ function crawl(dirPath, extensions = [
           const ext = path.extname(item).slice(1)
 
           if (extensions.includes(ext)) {
-            const track = {name: item, downloaderArg: itemPath}
+            // The name of the track doesn't include the file extension; a user
+            // probably wouldn't add the file extensions to a hand-written
+            // playlist, or want them in an auto-generated one.
+            const basename = path.basename(item, path.extname(item))
+
+            const track = {name: basename, downloaderArg: itemPath}
             return track
           } else {
             return null