public static String buildWebApplicationRootUrl(NetworkService networkService) {
    checkNotNull(networkService);

    if (!isWebService(networkService)) {
      return "http://"
          + NetworkEndpointUtils.toUriAuthority(networkService.getNetworkEndpoint())
          + "/";
    }

    String rootUrl =
        (isPlainHttp(networkService) ? "http://" : "https://")
            + buildWebUriAuthority(networkService)
            + buildWebAppRootPath(networkService);
    return rootUrl.endsWith("/") ? rootUrl : rootUrl + "/";
  }
@Test
  public void buildWebApplicationRootUrl_whenHttpServiceOnPort80_removesTrailingPortFromUrl() {
    assertThat(
        NetworkServiceUtils.buildWebApplicationRootUrl(
            NetworkService.newBuilder()
                .setNetworkEndpoint(forIpAndPort("127.0.0.1", 80))
                .setServiceName("http")
                .setServiceContext(
                    ServiceContext.newBuilder()
                        .setWebServiceContext(
                            WebServiceContext.newBuilder().setApplicationRoot("test_root")))
                .build()))
        .isEqualTo("http://127.0.0.1/test_root/");
  }