diff --git a/datasette/views/base.py b/datasette/views/base.py index aee06b01..bdc9f742 100644 --- a/datasette/views/base.py +++ b/datasette/views/base.py @@ -158,7 +158,7 @@ class BaseView: template_context["alternate_url_json"] = alternate_url_json headers.update( { - "Link": '{}; rel="alternate"; type="application/json+datasette"'.format( + "Link": '<{}>; rel="alternate"; type="application/json+datasette"'.format( alternate_url_json ) } diff --git a/datasette/views/database.py b/datasette/views/database.py index 7b081eae..33ee07b3 100644 --- a/datasette/views/database.py +++ b/datasette/views/database.py @@ -181,7 +181,7 @@ class DatabaseView(View): view_name="database", ), headers={ - "Link": '{}; rel="alternate"; type="application/json+datasette"'.format( + "Link": '<{}>; rel="alternate"; type="application/json+datasette"'.format( alternate_url_json ) }, @@ -630,7 +630,7 @@ class QueryView(View): data = {} headers.update( { - "Link": '{}; rel="alternate"; type="application/json+datasette"'.format( + "Link": '<{}>; rel="alternate"; type="application/json+datasette"'.format( alternate_url_json ) } diff --git a/datasette/views/table.py b/datasette/views/table.py index 82dab613..d87ac2aa 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -894,7 +894,7 @@ async def table_view_traced(datasette, request): ) headers.update( { - "Link": '{}; rel="alternate"; type="application/json+datasette"'.format( + "Link": '<{}>; rel="alternate"; type="application/json+datasette"'.format( alternate_url_json ) } diff --git a/docs/json_api.rst b/docs/json_api.rst index 5a28f042..3f696f39 100644 --- a/docs/json_api.rst +++ b/docs/json_api.rst @@ -457,7 +457,7 @@ You can find this near the top of the source code of those pages, looking like t The JSON URL is also made available in a ``Link`` HTTP header for the page:: - Link: https://latest.datasette.io/fixtures/sortable.json; rel="alternate"; type="application/json+datasette" + Link: ; rel="alternate"; type="application/json+datasette" .. _json_api_cors: diff --git a/tests/test_canned_queries.py b/tests/test_canned_queries.py index d1ed06d1..c84c8cdb 100644 --- a/tests/test_canned_queries.py +++ b/tests/test_canned_queries.py @@ -433,7 +433,7 @@ def test_canned_write_custom_template(canned_write_client): ) assert ( response.headers["link"] - == 'http://localhost/data/update_name.json; rel="alternate"; type="application/json+datasette"' + == '; rel="alternate"; type="application/json+datasette"' ) diff --git a/tests/test_html.py b/tests/test_html.py index 5766cea1..085fa037 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1040,7 +1040,7 @@ async def test_alternate_url_json(ds_client, path, expected): response = await ds_client.get(path) assert response.status_code == 200 link = response.headers["link"] - assert link == '{}; rel="alternate"; type="application/json+datasette"'.format( + assert link == '<{}>; rel="alternate"; type="application/json+datasette"'.format( expected ) assert (