Class RegexHelper

java.lang.Object
org.graylog2.system.urlwhitelist.RegexHelper

public class RegexHelper extends Object
Utility class to help creating an appropriate regex to be used in a whitelist entry.
  • Constructor Details

    • RegexHelper

      public RegexHelper()
  • Method Details

    • createRegexForUrlTemplate

      public String createRegexForUrlTemplate(String url, String placeholder)

      Replaces all placeholders in a "url template" with .*?, quotes everything else and adds ^ and $ to it.

      An example:

      https://example.com/api/lookup?key=${key}
      will become
      ^\Qhttps://example.com/api/lookup?key=\E.*?$

    • createRegexForUrl

      public String createRegexForUrl(String url)
      Quotes the url and adds a ^ and $.