Package 

Class HostPatternSanitizer


  • 
    public final class HostPatternSanitizer
    
                        

    Utility class to validate wildcard host patterns.

    A host pattern may contain at most one * wildcard and may only use the characters a-z, 0-9, ., - and *. A wildcard may only match subdomains of a registrable domain, so the * must be the last character of a subdomain label. Overly broad patterns (*, *.com, *.co.uk, *example.com) and mis-placed wildcards (*-preview.example.com) are rejected, while *.example.com, *.example.co.uk and preview-*.example.com are accepted.

    This is the counterpart of HostsSanitizer for entries that are allowed to carry a wildcard, and it only enforces the wildcard rules above. Wildcard-free entries are merely character-checked, not fully validated as host names (blanks, bare TLDs such as com, etc. are returned as-is), so callers should route wildcard-free entries through HostsSanitizer for proper host-name validation.

    • Method Summary

      Modifier and Type Method Description
      final List<String> validate(List<String> patterns, String feature) Validates the given host patterns, returning the valid ones in their original case and order (matching is case-insensitive, so the case is preserved for callers and normalized later).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HostPatternSanitizer

        HostPatternSanitizer(InternalLogger internalLogger)
        Parameters:
        internalLogger - the logger used to report dropped patterns to the user.
    • Method Detail

      • validate

         final List<String> validate(List<String> patterns, String feature)

        Validates the given host patterns, returning the valid ones in their original case and order (matching is case-insensitive, so the case is preserved for callers and normalized later). Entries containing characters outside [a-z0-9.*-], more than one * wildcard or an overly broad wildcard are dropped and an error is logged.

        Parameters:
        patterns - Host patterns to validate.
        feature - SDK feature requesting the validation.