Skip to content

Commit

Permalink
Use posixpath to construct URLs
Browse files Browse the repository at this point in the history
os.path.join is incorrect for constructing a URL on Windows because URLs
should always use forward slashes regardless of platform.
  • Loading branch information
asmeurer committed Sep 25, 2023
1 parent cf4951e commit 80d9ea8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions conda-store-server/conda_store_server/server/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import posixpath
import sys

import conda_store_server
Expand Down Expand Up @@ -198,9 +199,9 @@ def trim_slash(url):
app = FastAPI(
title="conda-store",
version=__version__,
openapi_url=os.path.join(self.url_prefix, "openapi.json"),
docs_url=os.path.join(self.url_prefix, "docs"),
redoc_url=os.path.join(self.url_prefix, "redoc"),
openapi_url=posixpath.join(self.url_prefix, "openapi.json"),
docs_url=posixpath.join(self.url_prefix, "docs"),
redoc_url=posixpath.join(self.url_prefix, "redoc"),
contact={
"name": "Quansight",
"url": "https://quansight.com",
Expand Down
3 changes: 2 additions & 1 deletion conda-store-server/conda_store_server/storage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
import os
import posixpath
import shutil

import minio
Expand Down Expand Up @@ -223,7 +224,7 @@ def get(self, key):
return f.read()

def get_url(self, key):
return os.path.join(self.storage_url, key)
return posixpath.join(self.storage_url, key)

def delete(self, db, build_id, key):
filename = os.path.join(self.storage_path, key)
Expand Down

0 comments on commit 80d9ea8

Please sign in to comment.