MCPcopy Create free account
hub / github.com/apache/tomcat / isAbsoluteURI

Method isAbsoluteURI

java/org/apache/tomcat/util/buf/UriUtil.java:258–278  ·  view source on GitHub ↗

Does the provided path start with file:/ or <protocol>:// . @param path The path to test @return true if the supplied path starts with one of the recognised sequences.

(String path)

Source from the content-addressed store, hash-verified

256 * @return {@code true} if the supplied path starts with one of the recognised sequences.
257 */
258 public static boolean isAbsoluteURI(String path) {
259 // Special case as only a single /
260 if (path.startsWith("file:/")) {
261 return true;
262 }
263
264 // Start at the beginning of the path and skip over any valid protocol
265 // characters
266 int i = 0;
267 while (i < path.length() && isSchemeChar(path.charAt(i))) {
268 i++;
269 }
270 // Need at least one protocol character. False positives with Windows
271 // drives such as C:/... will be caught by the later test for "://"
272 if (i == 0) {
273 return false;
274 }
275 // path starts with something that might be a protocol. Look for a
276 // following "://"
277 return i + 2 < path.length() && path.charAt(i++) == ':' && path.charAt(i++) == '/' && path.charAt(i) == '/';
278 }
279
280
281 /**

Callers 3

testMethod · 0.95
getResourceMethod · 0.95
getURIMethod · 0.95

Calls 4

isSchemeCharMethod · 0.95
lengthMethod · 0.80
charAtMethod · 0.80
startsWithMethod · 0.45

Tested by 1

testMethod · 0.76