diff --git a/norconex-commons-lang/src/changes/changes.xml b/norconex-commons-lang/src/changes/changes.xml index a7715517..98773eb0 100644 --- a/norconex-commons-lang/src/changes/changes.xml +++ b/norconex-commons-lang/src/changes/changes.xml @@ -7,7 +7,7 @@
-http
or https
, the port is -1 when
+ * Gets the URL port. If the protocol is other than
+ * http
or https
, the port is -1 when
* not specified.
* @return the URL port
*/
@@ -231,7 +231,7 @@ public int getPort() {
public void setPort(int port) {
this.port = port;
}
-
+
/**
* Gets the URL fragment.
* @return the fragment
@@ -251,7 +251,7 @@ public void setFragment(String fragment) {
/**
* Gets the last URL path segment without the query string.
- * If there are segment to return,
+ * If there are segment to return,
* an empty string will be returned instead.
* @return the last URL path segment
*/
@@ -264,7 +264,7 @@ public String getLastPathSegment() {
return segment;
}
/**
- * Converts this HttpURL to a regular {@link URL}, making sure
+ * Converts this HttpURL to a regular {@link URL}, making sure
* appropriate characters are escaped properly.
* @return a URL
* @throws URLException when URL is malformed
@@ -277,9 +277,9 @@ public URL toURL() {
throw new URLException("Cannot convert to URL: " + url, e);
}
}
-
+
/**
- * Gets the root of this HttpUrl. That is the left part of a URL up to
+ * Gets the root of this HttpUrl. That is the left part of a URL up to
* and including the host name. A null
or empty string returns
* a null
document root.
* @return left part of a URL up to (and including the host name
@@ -289,9 +289,9 @@ public URL toURL() {
public String getRoot() {
return getRoot(toString());
}
-
+
/**
- * Converts this HttpURL to a {@link URI}, making sure
+ * Converts this HttpURL to a {@link URI}, making sure
* appropriate characters are escaped properly.
* @return a URI
* @since 1.7.0
@@ -307,7 +307,7 @@ public URI toURI() {
}
/**
*
- * Converts the supplied URL to a {@link URL}, making sure
+ * Converts the supplied URL to a {@link URL}, making sure
* appropriate characters are encoded properly using UTF-8. This method
* is a short form of:
* new HttpURL("http://example.com").toURL();
@@ -321,7 +321,7 @@ public static URL toURL(String url) {
return new HttpURL(url).toURL();
}
/**
- *
Converts the supplied URL to a {@link URI}, making sure + *
Converts the supplied URL to a {@link URI}, making sure
* appropriate characters are encoded properly using UTF-8. This method
* is a short form of:
* new HttpURL("http://example.com").toURI();
@@ -336,7 +336,7 @@ public static URI toURI(String url) {
}
/**
- *
Gets the root of a URL. That is the left part of a URL up to and + *
Gets the root of a URL. That is the left part of a URL up to and
* including the host name. A null
or empty string returns
* a null
document root.
* This method is a short form of:
@@ -352,7 +352,7 @@ public static String getRoot(String url) {
}
return StringUtils.replacePattern(url, "(.*?://.*?)([/?#].*)", "$1");
}
-
+
/**
* Returns a string representation of this URL, properly encoded.
* @return URL as a string
@@ -390,7 +390,7 @@ public String toString() {
}
/**
- * Whether this URL uses the default port for the protocol. The default
+ * Whether this URL uses the default port for the protocol. The default
* port is 80 for "http" protocol, and 443 for "https". Other protocols
* are not supported and this method will always return false
* for them.
@@ -398,14 +398,14 @@ public String toString() {
* @since 1.8.0
*/
public boolean isPortDefault() {
- return PROTOCOL_HTTPS.equalsIgnoreCase(protocol)
+ return PROTOCOL_HTTPS.equalsIgnoreCase(protocol)
&& port == DEFAULT_HTTPS_PORT
|| PROTOCOL_HTTP.equalsIgnoreCase(protocol)
&& port == DEFAULT_HTTP_PORT;
}
-
+
/**
- *
URL-Encodes the query string portion of a URL. The entire + *
URL-Encodes the query string portion of a URL. The entire * string supplied is assumed to be a query string. * @param queryString URL query string * @return encoded path @@ -417,7 +417,7 @@ public static String encodeQueryString(String queryString) { } return new QueryString(queryString).toString(); } - + /** *
URL-Encodes a URL path. The entire string supplied is assumed * to be a URL path. Unsafe characters are percent-encoded using UTF-8 @@ -427,7 +427,7 @@ public static String encodeQueryString(String queryString) { * @since 1.7.0 */ public static String encodePath(String path) { - // Any characters that are not one of the following are + // Any characters that are not one of the following are // percent-encoded (including spaces): // a-z A-Z 0-9 . - _ ~ ! $ & ' ( ) * + , ; = : @ / % if (StringUtils.isBlank(path)) { @@ -448,10 +448,10 @@ public static String encodePath(String path) { bytes = Character.toString(ch).getBytes(StandardCharsets.UTF_8); for (byte b : bytes) { sb.append('%'); - int upper = (((int) b) >> 4) & 0xf; + int upper = ((b) >> 4) & 0xf; sb.append(Integer.toHexString( upper).toUpperCase(Locale.US)); - int lower = ((int) b) & 0xf; + int lower = (b) & 0xf; sb.append(Integer.toHexString( lower).toUpperCase(Locale.US)); } @@ -487,7 +487,7 @@ public static String toAbsolute(String baseURL, String relativeURL) { } // Relative to last directory/segment - if (!relURL.contains("://")) { + if (!relURL.contains(":")) { String base = baseURL.replaceFirst("(.*?)([\\?\\#])(.*)", "$1"); if (StringUtils.countMatches(base, '/') > 2) { base = base.replaceFirst("(.*/)(.*)", "$1"); @@ -503,7 +503,7 @@ public static String toAbsolute(String baseURL, String relativeURL) { // Not detected as relative, so return as is return relURL; } - + @Override public int hashCode() { return new HashCodeBuilder()