Class UrlUtils


  • public class UrlUtils
    extends Object
    • Constructor Detail

      • UrlUtils

        public UrlUtils()
    • Method Detail

      • isSafeUrl

        public static boolean isSafeUrl​(String returnUrl)
        Validate if passed URL uses HTTP or HTTPS schema or there's no indication that any type of schema is used altogether. This method expects URL decoded value as input. It is safe to pass Struts' action parameter which is URL decoded and trimmed.
        Parameters:
        returnUrl - URL decoded value of returnUrl query param
      • getPathUnderContext

        public static String getPathUnderContext​(@NotNull
                                                 @NotNull String url,
                                                 @NotNull
                                                 @NotNull String context)
        Given an URL which may: - include scheme,host and optionally port - start directly with context - start with an arbitrary path under a context this method returns the path under context. It should not be used for security purposes, because it operates on best effort basis - including returning the URL without modifications if context is not found .
        See Also:
        for context description