diff --git a/datasette/app.py b/datasette/app.py index fe461d42..cdfcb11d 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -468,7 +468,7 @@ class Datasette: self.jinja_env.filters["escape_sqlite"] = escape_sqlite self.jinja_env.filters["to_css_class"] = to_css_class pm.hook.prepare_jinja2_environment(env=self.jinja_env) - app.add_route(IndexView.as_view(self), "/") + app.add_route(IndexView.as_view(self), r"/") # TODO: /favicon.ico and /-/static/ deserve far-future cache expires app.add_route(favicon, "/favicon.ico") app.static("/-/static/", str(app_root / "datasette" / "static")) @@ -481,37 +481,37 @@ class Datasette: app.static(modpath, plugin["static_path"]) app.add_route( JsonDataView.as_view(self, "inspect.json", self.inspect), - "/-/inspect", + r"/-/inspect", ) app.add_route( JsonDataView.as_view(self, "metadata.json", lambda: self._metadata), - "/-/metadata", + r"/-/metadata", ) app.add_route( JsonDataView.as_view(self, "versions.json", self.versions), - "/-/versions", + r"/-/versions", ) app.add_route( JsonDataView.as_view(self, "plugins.json", self.plugins), - "/-/plugins", + r"/-/plugins", ) app.add_route( JsonDataView.as_view(self, "config.json", lambda: self._config), - "/-/config", + r"/-/config", ) app.add_route( - DatabaseDownload.as_view(self), "/" + DatabaseDownload.as_view(self), r"/" ) app.add_route( - DatabaseView.as_view(self), "/" + DatabaseView.as_view(self), r"/" ) app.add_route( TableView.as_view(self), - "//", + r"//", ) app.add_route( RowView.as_view(self), - "///", + r"///", ) self.register_custom_units() # On 404 with a trailing slash redirect to path without that slash: diff --git a/tests/test_html.py b/tests/test_html.py index 41af9b25..913eac94 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -687,7 +687,7 @@ def test_allow_download_on(app_client): "/fixtures" ) soup = Soup(response.body, 'html.parser') - assert len(soup.findAll('a', {'href': re.compile('\.db$')})) + assert len(soup.findAll('a', {'href': re.compile(r'\.db$')})) def test_allow_download_off(): @@ -699,7 +699,7 @@ def test_allow_download_off(): ) soup = Soup(response.body, 'html.parser') - assert not len(soup.findAll('a', {'href': re.compile('\.db$')})) + assert not len(soup.findAll('a', {'href': re.compile(r'\.db$')})) # Accessing URL directly should 403 response = client.get( "/fixtures.db",