Class URLValidator
java.lang.Object
me.remigio07.chatplugin.api.server.util.URLValidator
Util class used to validate URLs.
Every method except stripProtocol(String)
works only when ChatManager.isEnabled()
.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getDomainName
(String url) Gets the specified URL's domain name.Gets the list of the URLs contained in the input String.static String
stripProtocol
(String url) Strips the protocol from the specified URL.
-
Field Details
-
DOMAIN_NAME_PATTERN
Pattern representing the allowed domains.Regex: "^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,6}$"
- See Also:
-
-
Constructor Details
-
URLValidator
public URLValidator()
-
-
Method Details
-
getURLs
Gets the list of the URLs contained in the input String.URLs' domain names are checked using
getDomainName(String)
.You may modify the returned list.
- Parameters:
input
- Input containing URLs- Returns:
- URLs contained in given input
-
stripProtocol
Strips the protocol from the specified URL.Will return
url
if the specified URL is invalid or if it does not start with a valid protocol ("http://", "https://").- Parameters:
url
- URL to strip- Returns:
- URL without its protocol
-
getDomainName
Gets the specified URL's domain name.Will return
null
if the URL is invalid or if!
ChatManager.isEnabled()
or ifChatManager.getRecognizedTLDs()
does not contain the URL's TLD.- Parameters:
url
- Target URL- Returns:
- Specified URL's domain name
- See Also:
-