Skip to content

Commit 48fe5a8

Browse files
committed
urls.js: fix browsing directories with ! in patch
1 parent 510caaa commit 48fe5a8

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

docs/change-log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fixed "Add URL" not working
88
- Total playlist time status line is removed (foobar2000 only)
99
- Volume slider now uses linear scale instead of dB (foobar2000 only)
10+
- Fixed browsing directories with `!` in path
1011

1112
### Changes in v0.3 (released 2018-09-20):
1213
- Added button that locates currently played track

js/webui/src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ router.on({
5858

5959
'/files/!*': () => {
6060
navigationModel.setView(View.fileBrowser);
61+
6162
const path = getPathFromUrl(router.lastRouteResolved().url);
62-
fileBrowserModel.browse(path);
63+
64+
if (path)
65+
fileBrowserModel.browse(path);
6366
},
6467

6568
'/settings': () => {

js/webui/src/urls.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,10 @@ export default urls;
2727

2828
export function getPathFromUrl(url)
2929
{
30-
return decodeURIComponent(url.split('!', 2)[1]);
30+
const index = url.indexOf('!');
31+
32+
if (index < 0)
33+
return null;
34+
35+
return decodeURIComponent(url.substring(index + 1));
3136
}

0 commit comments

Comments
 (0)