def GetSegmentOfUrl(url: str, prefix: str) -> str:
    """
    Get the next segment from url following prefix. The return value is a segment without slash.

    For example, url = "projects/test-project/global/networks/n1",
    and prefix = "networks/", then the return value is "n1".
    """
    if not url: return ""
    if not prefix: return ""

    if not prefix.endswith("/"): prefix += "/"

    offset = url.find(prefix)
    if offset == -1: return ""

    offset += len(prefix)
    end = url.find("/", offset)
    if end == -1: end = len(url)

    return url[offset:end]