-
public final class HostPatternSanitizerUtility class to validate wildcard host patterns.
A host pattern may contain at most one
*wildcard and may only use the charactersa-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.ukandpreview-*.example.comare 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.
-
-
Constructor Summary
Constructors Constructor Description HostPatternSanitizer(InternalLogger internalLogger)
-
Method Summary
-
-
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.
-
-
-
-