You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to time constraints I downloaded the code and included into my source code to fix a bug when using :* paths. Unfortunately the wrong url with a different root context would be resolved simply because of the wild card.
The bug was on line 109 which had the following:
} else if (!token.equals(token)) {
but should read:
} else if (!currToken.equals(token)) {
Here is the method with the bug fix :
public Routed route(String path) {
final String[] tokens = Pattern.removeSlashAtBothEnds(path).split("/");
final Map<String, String> params = new HashMap<String, String>();
boolean matched = true;
for (final Pattern<T> pattern : patterns) {
final String[] currTokens = pattern.tokens();
final T target = pattern.target();
matched = true;
params.clear();
if (tokens.length == currTokens.length) {
for (int i = 0; i < currTokens.length; i++) {
final String token = tokens[i];
final String currToken = currTokens[i];
if (currToken.length() > 0 && currToken.charAt(0) == ':') {
params.put(currToken.substring(1), token);
} else if (!currToken.equals(token)) {
matched = false;
break;
}
}
} else if (currTokens.length > 0 && currTokens[currTokens.length - 1].equals(":*") && tokens.length >= currTokens.length) {
for (int i = 0; i < currTokens.length - 1; i++) {
final String token = tokens[i];
final String currToken = currTokens[i];
if (currToken.length() > 0 && currToken.charAt(0) == ':') {
params.put(currToken.substring(1), token);
} else if (!currToken.equals(token)) {
matched = false;
break;
}
}
if (matched) {
final StringBuilder b = new StringBuilder(tokens[currTokens.length - 1]);
for (int i = currTokens.length; i < tokens.length; i++) {
b.append('/');
b.append(tokens[i]);
}
params.put("*", b.toString());
}
} else {
matched = false;
}
if (matched) return new Routed<T>(target, false, params);
}
if (notFound != null) {
params.clear();
return new Routed<T>(notFound, true, params);
}
return null;
}
The text was updated successfully, but these errors were encountered:
Due to time constraints I downloaded the code and included into my source code to fix a bug when using :* paths. Unfortunately the wrong url with a different root context would be resolved simply because of the wild card.
The bug was on line 109 which had the following:
} else if (!token.equals(token)) {
but should read:
} else if (!currToken.equals(token)) {
Here is the method with the bug fix :
public Routed route(String path) {
final String[] tokens = Pattern.removeSlashAtBothEnds(path).split("/");
final Map<String, String> params = new HashMap<String, String>();
boolean matched = true;
}
The text was updated successfully, but these errors were encountered: