def validate_subdir()

in asfyaml/feature/website_staging.py [0:0]


def validate_subdir(subdir):
    """Validates a sub-directory for projects with multiple website repos."""
    if not re.match(r"^[-._a-zA-Z0-9/]+$", subdir):
        raise Exception(".asf.yaml: Invalid subdir '%s' - Should be [.-_a-zA-Z0-9/]+ only!" % subdir)
    if re.match(r".*\.\./.*", subdir):
        raise Exception(".asf.yaml: Invalid subdir '%s' - Usage of '../'!" % subdir)
    if subdir.startswith("/"):
        raise Exception(".asf.yaml: Invalid subdir '%s' - cannot start with a forward slash (/)!" % subdir)