code: def test_prefix_match(mock_longest_prefix_router):
      router = mock_longest_prefix_router
      router.update_routes(
          {
              EndpointTag("endpoint1", "default"): EndpointInfo(
                  route="/test/test2"
              ),
              EndpointTag("endpoint2", "default"): EndpointInfo(
                  route="/test"
              ),
              EndpointTag("endpoint3", "default"): EndpointInfo(
                  route="/"
              ),
          }
      )
  
      route, handle, _ = get_handle_function(router)(
          "/test/test2/subpath"
      )
      assert route == "/test/test2" and handle == "endpoint1"
      route, handle, _ = get_handle_function(router)("/test/test2/")
      assert route == "/test/test2" and handle == "endpoint1"
      route, handle, _ = get_handle_function(router)("/test/test2")
      assert route == "/test/test2" and handle == "endpoint1"
  
      route, handle, _ = get_handle_function(router)("/test/subpath")
      assert route == "/test" and handle == "endpoint2"
      route, handle, _ = get_handle_function(router)("/test/")
      assert route == "/test" and handle == "endpoint2"
      route, handle, _ = get_handle_function(router)("/test")
      assert route == "/test" and handle == "endpoint2"
  
      route, handle, _ = get_handle_function(router)("/test2")
      assert route == "/" and handle == "endpoint3"
      route, handle, _ = get_handle_function(router)("/")
      assert route == "/" and handle == "endpoint3"
  
file_path: ray/python/ray/serve/tests/test_proxy_router.py
imports: from typing import Callable
  import pytest
  from ray.serve._private.common import EndpointInfo, EndpointTag, RequestProtocol
  from ray.serve._private.proxy_router import EndpointRouter, LongestPrefixRouter, ProxyRouter
label_desc: Use image node_id 7 for calling a global function with example usage: test_prefix_match(mock_longest_prefix_router) without return types