Skip to content

Commit

Permalink
Tweak validator for raw license links
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Feb 7, 2025
1 parent 78be86c commit c69484b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions optimade/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class ServerConfig(BaseSettings):
] = "localhost:27017"

license: Annotated[
str | AnyHttpUrl | None,
AnyHttpUrl | str | None,
Field(
description="""Either an SPDX license identifier or a URL to a human-readable license, used to populate the `license` field in the info response.
Expand Down Expand Up @@ -480,7 +480,9 @@ def check_license_info(cls, value: Any) -> AnyHttpUrl | None:
if not value:
return None

if not isinstance(value, AnyHttpUrl):
try:
value = AnyHttpUrl(value)
except ValueError:
value = f"https://spdx.org/licenses/{value}"

# Check if license URL is accessible
Expand Down

0 comments on commit c69484b

Please sign in to comment.