Skip to content

Commit

Permalink
fix(validation): also allow URLs in download locations
Browse files Browse the repository at this point in the history
fix #761
fix #762

Signed-off-by: Maximilian Huber <maximilian.huber@tngtech.com>
  • Loading branch information
maxhbr authored and armintaenzertng committed Sep 19, 2023
1 parent 3d3100a commit ed9a135
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit ed9a135

Please sign in to comment.