{"html_url": "https://github.com/simonw/datasette/issues/394#issuecomment-451704724", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/394", "id": 451704724, "node_id": "MDEyOklzc3VlQ29tbWVudDQ1MTcwNDcyNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-01-06T00:32:23Z", "updated_at": "2019-01-06T00:33:44Z", "author_association": "OWNER", "body": "I found a really nice pattern for writing the unit tests for this (though it would look even nicer with a solution to #395)\r\n```python\r\n@pytest.mark.parametrize(\"prefix\", [\"/prefix/\", \"https://example.com/\"])\r\n@pytest.mark.parametrize(\"path\", [\r\n \"/\",\r\n \"/fixtures\",\r\n \"/fixtures/compound_three_primary_keys\",\r\n \"/fixtures/compound_three_primary_keys/a,a,a\",\r\n \"/fixtures/paginated_view\",\r\n])\r\ndef test_url_prefix_config(prefix, path):\r\n for client in make_app_client(config={\r\n \"url_prefix\": prefix,\r\n }):\r\n response = client.get(path)\r\n soup = Soup(response.body, \"html.parser\")\r\n for a in soup.findAll(\"a\"):\r\n href = a[\"href\"]\r\n if href not in {\r\n \"https://github.com/simonw/datasette\",\r\n \"https://github.com/simonw/datasette/blob/master/LICENSE\",\r\n \"https://github.com/simonw/datasette/blob/master/tests/fixtures.py\",\r\n }:\r\n assert href.startswith(prefix), (href, a.parent)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 396212021, "label": "base_url configuration setting"}, "performed_via_github_app": null}