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

Method extractFromPath

java/org/apache/catalina/util/ContextName.java:226–240  ·  view source on GitHub ↗

Extract the final component of the given path which is assumed to be a base name and generate a ContextName from that base name. @param path The path that ends in a base name @return the ContextName generated from the given base name

(String path)

Source from the content-addressed store, hash-verified

224 * @return the {@link ContextName} generated from the given base name
225 */
226 public static ContextName extractFromPath(String path) {
227 // Convert '\' to '/'
228 path = path.replace("\\", "/");
229 // Remove trailing '/'. Use while just in case a value ends in ///
230 while (path.endsWith("/")) {
231 path = path.substring(0, path.length() - 1);
232 }
233
234 int lastSegment = path.lastIndexOf('/');
235 if (lastSegment > 0) {
236 path = path.substring(lastSegment + 1);
237 }
238
239 return new ContextName(path, true);
240 }
241}

Callers 3

doGetMethod · 0.95
doPostMethod · 0.95

Calls 3

endsWithMethod · 0.80
lengthMethod · 0.80
replaceMethod · 0.45

Tested by 1