Class UrlPathUtil

java.lang.Object
ca.cdr.test.util.UrlPathUtil

public final class UrlPathUtil extends Object
Helpers for the URL paths under which Smile CDR modules are served.
  • Method Details

    • normalizeContextPath

      @Nonnull public static String normalizeContextPath(@Nullable String theContextPath)
      Normalizes a module's context_path so that it can be appended to a protocol://host:port root as-is.
      Parameters:
      theContextPath - the configured context path; null, blank and / all mean the root
      Returns:
      the empty string for the root, otherwise the path with one leading slash and no trailing slash, such as /fhir-request
    • withTrailingSlash

      @Nonnull public static String withTrailingSlash(@Nonnull String theBaseUrl)
      Spring's RestClient appends a request's URI template to the base URL's path verbatim, so a base URL with a context path and no trailing slash turns module-config/ into /admin-jsonmodule-config/. With the trailing slash, both module-config/ and /module-config/ resolve beneath the context path.
      Parameters:
      theBaseUrl - a base URL, with or without a trailing slash
      Returns:
      the same URL ending in exactly one slash