diff options
author | Florrie <towerofnix@gmail.com> | 2018-06-26 11:59:28 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-06-26 12:00:54 -0300 |
commit | 84ad73f638fe0b03e173b8ffb545d8edb43acc3c (patch) | |
tree | 298aed3ff3f1524fcf40633f85f432df18baf4d5 /crawlers.js | |
parent | 3c0cd5c2a98685ab9fd0fdf97a1ac28ceb97dc74 (diff) |
File:// support in crawl-local
Diffstat (limited to 'crawlers.js')
-rw-r--r-- | crawlers.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crawlers.js b/crawlers.js index 61f422b..82ef78e 100644 --- a/crawlers.js +++ b/crawlers.js @@ -190,6 +190,17 @@ function crawlLocal(dirPath, extensions = [ 'wav', 'mp3', 'mp4', 'm4a', 'aac', 'mod' ]) { + // If the passed path is a file:// URL, try to decode it: + try { + const url = new URL(dirPath) + if (url.protocol === 'file:') { + dirPath = decodeURIComponent(url.pathname) + } + } catch (error) { + // If it's not a URL, don't do anything special - it's (assumedly) an + // ordinary path ("/path/to/the directory"). + } + return readDir(dirPath).then(items => { items.sort(sortIgnoreCase(naturalSort())) |