Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure urls do not contain backward slashes on windows (#67) #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions binary_database_files/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from urllib.parse import urljoin

from django.conf import settings
from django.urls import reverse
Expand All @@ -14,7 +14,7 @@ def URL_METHOD_1(name):
"""
Construct file URL based on media URL.
"""
return os.path.join(settings.MEDIA_URL, name)
return urljoin(settings.MEDIA_URL, name)


def URL_METHOD_2(name):
Expand Down
3 changes: 2 additions & 1 deletion binary_database_files/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def url(self, name):
We could also raise an error like the SFTP backend of django-storages is doing, but the relative URL is the
previous behavior so we fall back to that.
"""
return "{}{}".format(self._base_url, settings.DATABASE_FILES_URL_METHOD(name))
url_name = name.replace('\\', '/')
return "{}{}".format(self._base_url, settings.DATABASE_FILES_URL_METHOD(url_name))

def size(self, name):
"""Return the size of the file with filename `name` in bytes."""
Expand Down