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

fix(validation): also allow URLs in download locations #763

Merged
merged 1 commit into from
Sep 19, 2023
Merged
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 src/spdx_tools/spdx/validation/uri_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def validate_url(url: str) -> List[str]:


def validate_download_location(location: str) -> List[str]:
if not re.match(download_location_pattern, location):
return [f"must be a valid download location according to the specification, but is: {location}"]
if not (validate_url(location) == [] or re.match(download_location_pattern, location)):
return [f"must be a valid URL or download location according to the specification, but is: {location}"]

return []

Expand Down
4 changes: 3 additions & 1 deletion tests/spdx/validation/test_uri_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
)
def test_valid_url(input_value):
assert validate_url(input_value) == []
# URLs are also valid download locations:
assert validate_download_location(input_value) == []


# TODO: more negative examples: https://github.com/spdx/tools-python/issues/377
Expand Down Expand Up @@ -92,7 +94,7 @@ def test_valid_package_download_location(input_value):
)
def test_invalid_package_download_location(input_value):
assert validate_download_location(input_value) == [
f"must be a valid download location according to the specification, but is: {input_value}"
f"must be a valid URL or download location according to the specification, but is: {input_value}"
]


Expand Down