From 69bf85e11d3c78f0ed00663dd489b92509e6ed0e Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 5 Jun 2021 11:37:56 -0700 Subject: [PATCH] Revert "First attempt at a fix for #1238, but flawed" This reverts commit 9fc64360fc6f9cfe7644e8f0defeaf2eb00c7297. --- datasette/app.py | 10 +++------- datasette/utils/testing.py | 2 -- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/datasette/app.py b/datasette/app.py index db79e8d3f2..018a8d5b3b 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -1088,10 +1088,7 @@ async def route_path(self, scope, receive, send, path): # Strip off base_url if present before routing base_url = self.ds.setting("base_url") if base_url != "/" and path.startswith(base_url): - # print("Before path:", path) path = "/" + path[len(base_url) :] - scope = dict(scope, path=path, raw_path=path.encode("utf-8")) - # print(f"{path=}\n{base_url=}\n{scope=}") request = Request(scope, receive) # Populate request_messages if ds_messages cookie is present try: @@ -1359,8 +1356,8 @@ def __init__(self, ds): self.ds = ds self.app = ds.app() - def _fix(self, path, avoid_path_rewrites=False): - if not isinstance(path, PrefixedUrlString) and not avoid_path_rewrites: + def _fix(self, path): + if not isinstance(path, PrefixedUrlString): path = self.ds.urls.path(path) if path.startswith("/"): path = f"http://localhost{path}" @@ -1396,5 +1393,4 @@ async def delete(self, path, **kwargs): async def request(self, method, path, **kwargs): async with httpx.AsyncClient(app=self.app) as client: - avoid_path_rewrites = kwargs.pop("avoid_path_rewrites", None) - return await client.request(method, self._fix(path, avoid_path_rewrites), **kwargs) + return await client.request(method, self._fix(path), **kwargs) diff --git a/datasette/utils/testing.py b/datasette/utils/testing.py index 5037de1c4f..57b19ea54e 100644 --- a/datasette/utils/testing.py +++ b/datasette/utils/testing.py @@ -1,6 +1,5 @@ from asgiref.sync import async_to_sync from urllib.parse import urlencode -from datasette.utils import PrefixedUrlString import json # These wrapper classes pre-date the introduction of @@ -141,7 +140,6 @@ async def _request( method, path, allow_redirects=allow_redirects, - avoid_path_rewrites=True, cookies=cookies, headers=headers, content=post_body,