diff --git a/src/datasette_reconcile/__about__.py b/src/datasette_reconcile/__about__.py index 6bb90b6..7b405c8 100644 --- a/src/datasette_reconcile/__about__.py +++ b/src/datasette_reconcile/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2023-present David Kane # # SPDX-License-Identifier: MIT -__version__ = "0.4.1" +__version__ = "0.5.0" diff --git a/src/datasette_reconcile/reconcile.py b/src/datasette_reconcile/reconcile.py index 64d310d..22de4f6 100644 --- a/src/datasette_reconcile/reconcile.py +++ b/src/datasette_reconcile/reconcile.py @@ -220,9 +220,11 @@ async def _service_manifest(self, request): if "x-forwarded-proto" in request.headers: scheme = request.headers.get("x-forwarded-proto") - service_url = ( - f'{scheme}://{request.host}{self.datasette.setting("base_url")}/{self.database}/{self.table}/-/reconcile' - ) + base_url = f'{scheme}://{request.host}{self.datasette.setting("base_url")}' + if not base_url.endswith("/"): + base_url += "/" + + service_url = f"{base_url}{self.database}/{self.table}/-/reconcile" view_url = self.config.get("view_url") if not view_url: diff --git a/tests/test_reconcile.py b/tests/test_reconcile.py index c48350f..2a3b530 100644 --- a/tests/test_reconcile.py +++ b/tests/test_reconcile.py @@ -101,8 +101,24 @@ async def test_servce_manifest_view_extend(db_path): assert 200 == response.status_code data = response.json() assert "extend" in data - assert data["extend"]["propose_properties"]["service_url"] == "http://localhost//test/dogs/-/reconcile" + assert data["extend"]["propose_properties"]["service_url"] == "http://localhost/test/dogs/-/reconcile" assert data["extend"]["property_settings"][3]["name"] == "status" + + +@pytest.mark.asyncio +@pytest.mark.parametrize("suggest_type", ["entity", "type", "property"]) +async def test_servce_manifest_view_suggest(db_path, suggest_type): + app = Datasette( + [db_path], + metadata=plugin_metadata({"name_field": "name"}), + ).app() + async with httpx.AsyncClient(app=app) as client: + response = await client.get("http://localhost/test/dogs/-/reconcile") + assert 200 == response.status_code + data = response.json() + assert "extend" in data + assert data["suggest"][suggest_type]["service_url"] == "http://localhost/test/dogs/-/reconcile" + assert data["suggest"][suggest_type]["service_path"] == f"/suggest/{suggest_type}" assert len(data["suggest"]) == 3