def make_url_path_regex(*path):
    """Get a regex of the form ^/foo/bar/baz/?$ for a path (foo, bar, baz)."""
    path = [x.strip("/") for x in path if x]  # Filter out falsy components.
    return r"^/%s/?$" % "/".join(path)