12 lines
582 B
Python
12 lines
582 B
Python
def validate_overlay_ref(raw: str) -> str:
|
|
if raw != raw.strip():
|
|
raise ValueError("overlay ref must not have leading or trailing whitespace")
|
|
if not raw:
|
|
raise ValueError("overlay ref must not be empty")
|
|
if "\\" in raw:
|
|
raise ValueError("overlay ref must use forward slashes")
|
|
if raw.startswith("/"):
|
|
raise ValueError("overlay ref must be relative")
|
|
if any(component in {"", ".", ".."} for component in raw.split("/")):
|
|
raise ValueError("overlay ref must not contain empty, current, or parent components")
|
|
return raw
|