Class SafeUrl

java.lang.Object
io.mindspice.simplypages.core.SafeUrl

public final class SafeUrl extends Object
Shared URL validation helpers for component attributes and inline CSS URL values.
  • Method Details

    • validateHref

      public static void validateHref(String url)
      Validates hyperlink-style URLs.

      Allowed values are empty/null, fragment URLs, root/current/parent-relative URLs, protocol-relative URLs, query-only URLs, and absolute URLs with http, https, mailto, or tel schemes.

      Parameters:
      url - URL value to validate
      Throws:
      IllegalArgumentException - when the URL uses a disallowed scheme
    • validateCssImageUrl

      public static void validateCssImageUrl(String url)
      Validates an image URL before embedding it inside a CSS url(...) value.

      This intentionally permits the same absolute/relative URL families as hyperlinks except mailto and tel. It also rejects CSS token delimiters that could break out of the generated url("...") value.

      Parameters:
      url - image URL
      Throws:
      IllegalArgumentException - when the URL cannot be safely embedded in CSS
    • cssUrl

      public static String cssUrl(String url)
      Builds a trusted CSS url("...") value after validation.
      Parameters:
      url - image URL
      Returns:
      CSS url function value