Class UrlStringUtils

java.lang.Object
org.owasp.dependencycheck.utils.UrlStringUtils

@ThreadSafe public final class UrlStringUtils extends Object
Author:
Jeremy Long
  • Method Details

    • containsUrl

      public static boolean containsUrl(String text)
      Tests if the text provided contains a URL. This is somewhat limited search in that it only looks for (ftp|http|https)://
      Parameters:
      text - the text to search
      Returns:
      true if the text contains a url, otherwise false
    • isUrl

      public static boolean isUrl(String text)
      Tests if the given text is url.
      Parameters:
      text - the string to test
      Returns:
      returns true if the text is a url, otherwise false
    • extractImportantUrlData

      public static List<String> extractImportantUrlData(String text) throws MalformedURLException

      Takes a URL, in String format, and adds the important parts of the URL to a list of strings.

      Example, given the following input:

      "https://www.somedomain.com/path1/path2/file.php?id=439"

      The function would return:

      {"some.domain", "path1", "path2", "file"}
      Parameters:
      text - a URL
      Returns:
      importantParts a list of the important parts of the URL
      Throws:
      MalformedURLException - thrown if the URL is malformed