diff --git a/docs/changelog.md b/docs/changelog.md index a9c66b40..bb0f1f01 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 2.1.1 - 2024-03-25 + +- fix Path.replace called instead of str.replace + ## 2.1.0 - 2024-03-25 ### Bug fixes diff --git a/umap/__init__.py b/umap/__init__.py index 127c148a..5b0431ec 100644 --- a/umap/__init__.py +++ b/umap/__init__.py @@ -1 +1 @@ -VERSION = "2.1.0" +VERSION = "2.1.1" diff --git a/umap/tests/test_datalayer_views.py b/umap/tests/test_datalayer_views.py index 39374221..6055e47e 100644 --- a/umap/tests/test_datalayer_views.py +++ b/umap/tests/test_datalayer_views.py @@ -44,6 +44,16 @@ def test_get_with_public_mode(client, settings, datalayer, map): assert j["type"] == "FeatureCollection" +def test_get_with_x_accel_redirect(client, settings, datalayer, map): + settings.UMAP_XSENDFILE_HEADER = "X-Accel-Redirect" + url = reverse("datalayer_view", args=(map.pk, datalayer.pk)) + response = client.get(url) + assert response.status_code == 200 + assert "X-Accel-Redirect" in response.headers + assert response["X-Accel-Redirect"].startswith("/internal/datalayer/") + assert response["X-Accel-Redirect"].endswith(".geojson") + + def test_get_with_open_mode(client, settings, datalayer, map): map.share_status = Map.PUBLIC map.save() diff --git a/umap/views.py b/umap/views.py index b9769599..3a8d1743 100644 --- a/umap/views.py +++ b/umap/views.py @@ -1020,8 +1020,8 @@ class DataLayerView(GZipMixin, BaseDetailView): if getattr(settings, "UMAP_XSENDFILE_HEADER", None): response = HttpResponse() - path = path.replace(settings.MEDIA_ROOT, "/internal") - response[settings.UMAP_XSENDFILE_HEADER] = path + internal_path = str(path).replace(settings.MEDIA_ROOT, "/internal") + response[settings.UMAP_XSENDFILE_HEADER] = internal_path else: # Do not use in production # (no gzip/cache-control/If-Modified-Since/If-None-Match)