compress
public static byte[] compress(String urlString)
throws MalformedURLException
Converts the given URL string into a byte array "compressed" version of the URL.
The regex needs to determine what the URL starts with and what the hostname ends
with. The URL must start with one of the following:
http://www.
https://www.
http://
https://
The hostname may end with one of the following TLDs:
.com
.org
.edu
.net
.info
.biz
.gov
If the path component of the URL is non-empty, then the "slash" version of
the matching TLD can be used. Otherwise, the "non-slash" version of the TLD is used.
If the hostname doesn't end with a TLD, that's fine; it just isn't compressed
into a single byte.
Therefore, the following regex should tell me what I need to know about the URL:
^(http|https):\/\/(www.)?((?:[0-9a-z_-]+\.??)+)(\.[0-9a-z_-]+\/?)(.*)$
Groups:
1: http or https
2: www. or empty
3: hostname including optional leading www. but excluding trailing dot up to but not including TLD
4: TLD with leading dot and optional trailing slash
5: path without leading slash or empty
- Parameters:
urlString -
- Returns:
- Throws:
MalformedURLException