Skip to content

Commit

Permalink
Ensure starting slash for root_path
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Mar 9, 2021
1 parent 1235326 commit 863c0bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions optimade/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def remove_end_slashes(cls, value: str) -> str:
if isinstance(value, str):
while value.endswith("/"):
value = value[:-1]
while value.startswith("/"):
value = value[1:]
value = f"/{value}"
return value

@root_validator(pre=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"debug": false,
"default_db": "test_server",
"base_url": "http://example.org",
"root_path": "/custom_root_path/",
"root_path": "custom_root_path/",
"implementation": {
"name": "Example implementation",
"source_url": "https://github.com/Materials-Consortia/optimade-python-tools",
Expand Down

0 comments on commit 863c0bb

Please sign in to comment.