Skip to content

Commit cf1895a

Browse files
committed
Small fix to avoid the situation where the inputs contain "." and then we end up with a
urn which is invalid
1 parent 2425baf commit cf1895a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

aces/idt/core/transform_id.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,26 @@ def generate_idt_urn(
101101
-------
102102
:class:`str`
103103
The generated URN in the format described.
104+
105+
Notes
106+
-----
107+
- Dots in the colorspace_vendor, encoding_colourspace, and
108+
encoding_transfer_function strings are replaced with underscores to
109+
ensure valid URN format, as dots are used as delimiters in the URN.
104110
"""
105111

112+
# Sanitize input strings by replacing dots with underscores
113+
colorspace_vendor_clean = colorspace_vendor.replace(".", "_")
114+
encoding_colourspace_clean = encoding_colourspace.replace(".", "_")
115+
encoding_transfer_function_clean = encoding_transfer_function.replace(".", "_")
116+
106117
urn_prefix = ACES_URN_PREFIX.format(aces_transform_type=AcesTransformType.CSC.value)
107118
hash_id = generate_truncated_hash()
108-
colorspace_name = f"{encoding_colourspace}_{encoding_transfer_function}_{hash_id}"
119+
colorspace_name = (
120+
f"{encoding_colourspace_clean}_{encoding_transfer_function_clean}_{hash_id}"
121+
)
109122
return (
110-
f"{urn_prefix}.{colorspace_vendor}.{colorspace_name}.a{ACES_MAJOR_VERSION}"
123+
f"{urn_prefix}.{colorspace_vendor_clean}.{colorspace_name}.a{ACES_MAJOR_VERSION}"
111124
f".v{version_number}"
112125
)
113126

0 commit comments

Comments
 (0)