/** * Same as {@link #pathStartsWith(String, String)} but returns <jk>true</jk> if at least one prefix matches. * * @param path The path to check. * @param pathPrefixes The prefixes. * @return <jk>true</jk> if the specified path string is prefixed with any of the specified prefixes. */ public static boolean pathStartsWith(String path, String[] pathPrefixes) { for (String p : pathPrefixes) if (pathStartsWith(path, p)) return true; return false; }
/** * Same as {@link #pathStartsWith(String, String)} but returns <jk>true</jk> if at least one prefix matches. * * @param path The path to check. * @param pathPrefixes The prefixes. * @return <jk>true</jk> if the specified path string is prefixed with any of the specified prefixes. */ public static boolean pathStartsWith(String path, String[] pathPrefixes) { for (String p : pathPrefixes) if (pathStartsWith(path, p)) return true; return false; }
/** * Same as {@link #pathStartsWith(String, String)} but returns <jk>true</jk> if at least one prefix matches. * * @param path The path to check. * @param pathPrefixes The prefixes. * @return <jk>true</jk> if the specified path string is prefixed with any of the specified prefixes. */ public static boolean pathStartsWith(String path, String[] pathPrefixes) { for (String p : pathPrefixes) if (pathStartsWith(path, p)) return true; return false; }
/** * Returns <jk>true</jk> if the specified path refers to a static file. * * <p> * Static files are files pulled from the classpath and served up directly to the browser. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link RestContext#REST_staticFiles} * </ul> * * @param p The URL path remainder after the servlet match. * @return <jk>true</jk> if the specified path refers to a static file. */ public boolean isStaticFile(String p) { return pathStartsWith(p, staticFilesPaths); }
/** * Returns <jk>true</jk> if the specified path refers to a static file. * * <p> * Static files are files pulled from the classpath and served up directly to the browser. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link RestContext#REST_staticFiles} * </ul> * * @param p The URL path remainder after the servlet match. * @return <jk>true</jk> if the specified path refers to a static file. */ public boolean isStaticFile(String p) { return pathStartsWith(p, staticFilesPaths); }
/** * Returns <jk>true</jk> if the specified path refers to a static file. * * <p> * Static files are files pulled from the classpath and served up directly to the browser. * * <h5 class='section'>See Also:</h5> * <ul> * <li class='jf'>{@link RestContext#REST_staticFiles} * </ul> * * @param p The URL path remainder after the servlet match. * @return <jk>true</jk> if the specified path refers to a static file. */ public boolean isStaticFile(String p) { return pathStartsWith(p, staticFilesPaths); }
@Test public void testPathStartsWith() throws Exception { assertTrue(pathStartsWith("foo", "foo")); assertTrue(pathStartsWith("foo/bar", "foo")); assertFalse(pathStartsWith("foo2/bar", "foo")); assertFalse(pathStartsWith("foo2", "foo")); assertFalse(pathStartsWith("foo2", "")); }
else if (p.equals("style.css")) r = styleSheet; else if (StringUtils.pathStartsWith(p, staticFilesPrefixes)) r = resolveStaticFile(p);