def starts_or_ends_with(s, w):
    """Returns ``True`` if string `s` starts or ends with string `w`, case
    insensitively."""
    lower = s.split('/')[-1].lower()
    return lower.startswith(w) or lower.endswith(w)