Skip to content

Commit c69484b

Browse files
committed
Tweak validator for raw license links
1 parent 78be86c commit c69484b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

optimade/server/config.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class ServerConfig(BaseSettings):
240240
] = "localhost:27017"
241241

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

483-
if not isinstance(value, AnyHttpUrl):
483+
try:
484+
value = AnyHttpUrl(value)
485+
except ValueError:
484486
value = f"https://spdx.org/licenses/{value}"
485487

486488
# Check if license URL is accessible

0 commit comments

Comments
 (0)