diff --git a/src/h_vialib/client.py b/src/h_vialib/client.py index d3f53a7..bd6afc5 100644 --- a/src/h_vialib/client.py +++ b/src/h_vialib/client.py @@ -13,6 +13,7 @@ class ContentType(str, Enum): PDF = "pdf" HTML = "html" + VIDEO = "video" class ViaDoc: @@ -102,8 +103,12 @@ def _url_for(self, doc, query): if self._service_url is None: raise ValueError("Cannot rewrite URLs without a service URL") - # Optimisation to skip routing for documents we know are PDFs - path = "/pdf" if doc.content_type == ContentType.PDF else "/route" + # Optimisation to skip routing for documents we know the type of + content_type_paths = { + ContentType.PDF: "/pdf", + ContentType.VIDEO: "/video", + } + path = content_type_paths.get(doc.content_type, "/route") query["url"] = doc.url diff --git a/tests/unit/h_vialib/client_test.py b/tests/unit/h_vialib/client_test.py index 4691f2e..6818d78 100644 --- a/tests/unit/h_vialib/client_test.py +++ b/tests/unit/h_vialib/client_test.py @@ -32,7 +32,9 @@ class TestViaClient: "via.external_link_mode": "new-tab", } - @pytest.mark.parametrize("content_type,path", ((None, "/route"), ("pdf", "/pdf"))) + @pytest.mark.parametrize( + "content_type,path", ((None, "/route"), ("pdf", "/pdf"), ("video", "/video")) + ) def test_url_for(self, client, content_type, path): url = "http://example.com&a=1&a=2"