Просмотр исходного кода

feat: Add canonical link http header to the static response

Cristian 5 лет назад
Родитель
Сommit
83e5b019e4
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      archivebox/core/views.py

+ 3 - 1
archivebox/core/views.py

@@ -107,7 +107,9 @@ class LinkDetails(View):
         # slug is a timestamp
         by_ts = {page.timestamp: page for page in all_pages}
         try:
-            return static.serve(request, archivefile, by_ts[slug].link_dir, show_indexes=True)
+            response = static.serve(request, archivefile, by_ts[slug].link_dir, show_indexes=True)
+            response["Link"] = f'<{by_ts[slug].url}>; rel="canonical"'
+            return response
         except KeyError:
             pass