question: private static boolean urlMatches ( String url , String template ) { if ( TextUtils . isEmpty ( url ) || TextUtils . isEmpty ( template ) ) { return false ; } String pattern = '^' + template ; if ( template . charAt ( template . length ( ) - 1 ) != '/' ) { pattern += "/?" ; } pattern += "(\\?.*)?$" ; return url . matches ( pattern ) ; }
target:  Match url to a regex template while allowing extra slash and query strings at the end