|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
"""Path handling"""
|
|
|
|
|
|
|
|
|
|
from .exc import ValidationError
|
|
|
|
|
from .identity import Identity
|
|
|
|
|
from .types import ALPHA_LOWER, ALPHA_UPPER, DIGIT
|
|
|
|
|
|
|
|
|
@ -22,25 +23,25 @@ class Path:
|
|
|
|
|
"""Validate a path"""
|
|
|
|
|
|
|
|
|
|
if not 2 <= len(path) <= 512:
|
|
|
|
|
raise ValueError('Path length must be between 2 and 512')
|
|
|
|
|
raise ValidationError('Path length must be between 2 and 512')
|
|
|
|
|
|
|
|
|
|
if not path.startswith('/'):
|
|
|
|
|
raise ValueError('Paths must start with a /')
|
|
|
|
|
raise ValidationError('Paths must start with a /')
|
|
|
|
|
|
|
|
|
|
if path.endswith('/'):
|
|
|
|
|
raise ValueError('Paths must not end with a /')
|
|
|
|
|
raise ValidationError('Paths must not end with a /')
|
|
|
|
|
|
|
|
|
|
if path.startswith('/@'):
|
|
|
|
|
raise ValueError('Paths must not start with /@')
|
|
|
|
|
raise ValidationError('Paths must not start with /@')
|
|
|
|
|
|
|
|
|
|
if '//' in path:
|
|
|
|
|
raise ValueError('Paths must not contain //')
|
|
|
|
|
raise ValidationError('Paths must not contain //')
|
|
|
|
|
|
|
|
|
|
if path.count('!') > 1:
|
|
|
|
|
raise ValueError('Only one ! is allowed in paths')
|
|
|
|
|
raise ValidationError('Only one ! is allowed in paths')
|
|
|
|
|
|
|
|
|
|
if '!' in path and not allow_ephemeral:
|
|
|
|
|
raise ValueError('Only ephemeral paths may contain !')
|
|
|
|
|
raise ValidationError('Only ephemeral paths may contain !')
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def is_shared(self) -> bool:
|
|
|
|
|