Skip to content

Commit

Permalink
fix: allow blank extensions and slash extension to be valid
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 23, 2021
1 parent 210c5fe commit 70ddb7a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions datagateway_api/src/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ def validate_extension(extension):
"""
extension = extension.strip()

if not extension.startswith("/"):
raise ValueError("must start with '/'")
if extension.endswith("/"):
raise ValueError("must not end with '/'")
if extension:
if not extension.startswith("/"):
raise ValueError("must start with '/'")
if extension.endswith("/") and len(extension) != 1:
raise ValueError("must not end with '/'")

return extension

Expand Down

0 comments on commit 70ddb7a

Please sign in to comment.