Remove JSON rel=alternate from some pages, closes #1623

pull/1626/head
Simon Willison 2022-02-02 13:48:52 -08:00
rodzic 8d5779acf0
commit 23a09b0f6a
2 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -43,6 +43,7 @@ class JsonDataView(BaseView):
class PatternPortfolioView(BaseView):
name = "patterns"
has_json_alternate = False
async def get(self, request):
await self.check_permission(request, "view-instance")
@ -51,6 +52,7 @@ class PatternPortfolioView(BaseView):
class AuthTokenView(BaseView):
name = "auth_token"
has_json_alternate = False
async def get(self, request):
token = request.args.get("token") or ""
@ -69,6 +71,7 @@ class AuthTokenView(BaseView):
class LogoutView(BaseView):
name = "logout"
has_json_alternate = False
async def get(self, request):
if not request.actor:
@ -88,6 +91,7 @@ class LogoutView(BaseView):
class PermissionsDebugView(BaseView):
name = "permissions_debug"
has_json_alternate = False
async def get(self, request):
await self.check_permission(request, "view-instance")
@ -103,6 +107,7 @@ class PermissionsDebugView(BaseView):
class AllowDebugView(BaseView):
name = "allow_debug"
has_json_alternate = False
async def get(self, request):
errors = []
@ -137,6 +142,7 @@ class AllowDebugView(BaseView):
class MessagesDebugView(BaseView):
name = "messages_debug"
has_json_alternate = False
async def get(self, request):
await self.check_permission(request, "view-instance")

Wyświetl plik

@ -922,3 +922,15 @@ def test_alternate_url_json(app_client, path, expected):
)
in response.text
)
@pytest.mark.parametrize(
"path",
("/-/patterns", "/-/messages", "/-/allow-debug", "/fixtures.db"),
)
def test_no_alternate_url_json(app_client, path):
response = app_client.get(path)
assert "link" not in response.headers
assert (
'<link rel="alternate" type="application/json+datasette"' not in response.text
)