diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 7977eda94..f955b6d63 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -176,11 +176,16 @@ class QueryConverter(PathConverter): return ','.join(value) +class EverythingConverter(PathConverter): + regex = '.*?' + + # Flask setup. app = flask.Flask(__name__) app.url_map.converters['idlist'] = IdListConverter app.url_map.converters['query'] = QueryConverter +app.url_map.converters['everything'] = EverythingConverter @app.before_request @@ -221,9 +226,9 @@ def item_query(queries): return g.lib.items(queries) -@app.route('/item/path/') +@app.route('/item/path/') def item_at_path(path): - query = beets.library.PathQuery('path', b'/' + path.encode('utf-8')) + query = beets.library.PathQuery('path', path.encode('utf-8')) item = g.lib.items(query).get() if item: return flask.jsonify(_rep(item)) diff --git a/test/test_web.py b/test/test_web.py index 867e2c3e3..98347d8af 100644 --- a/test/test_web.py +++ b/test/test_web.py @@ -79,7 +79,7 @@ class WebPluginTest(_common.LibTestCase): def test_get_single_item_by_path(self): data_path = os.path.join(_common.RSRC, b'full.mp3') self.lib.add(Item.from_path(data_path)) - response = self.client.get('/item/path' + data_path.decode('utf-8')) + response = self.client.get('/item/path/' + data_path.decode('utf-8')) response.json = json.loads(response.data.decode('utf-8')) self.assertEqual(response.status_code, 200) @@ -89,7 +89,7 @@ class WebPluginTest(_common.LibTestCase): data_path = os.path.join(_common.RSRC, b'full.mp3') # data_path points to a valid file, but we have not added the file # to the library. - response = self.client.get('/item/path' + data_path.decode('utf-8')) + response = self.client.get('/item/path/' + data_path.decode('utf-8')) self.assertEqual(response.status_code, 404)