Skip to content

Commit

Permalink
Revert "First attempt at a fix for #1238, but flawed"
Browse files Browse the repository at this point in the history
This reverts commit 9fc6436.
  • Loading branch information
simonw committed Jun 5, 2021
1 parent 9fc6436 commit 69bf85e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 3 additions & 7 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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)
2 changes: 0 additions & 2 deletions datasette/utils/testing.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -141,7 +140,6 @@ async def _request(
method,
path,
allow_redirects=allow_redirects,
avoid_path_rewrites=True,
cookies=cookies,
headers=headers,
content=post_body,
Expand Down

0 comments on commit 69bf85e

Please sign in to comment.