Skip to content

Commit

Permalink
Improve Path/PathParam URI robusness
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Jun 15, 2011
1 parent f9ade2d commit ee04f6d
Showing 1 changed file with 11 additions and 5 deletions.
Expand Up @@ -223,7 +223,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
final Path atClass = clazz.getAnnotation(Path.class);

if (atClass != null) {
rawUrl.append(atClass.value());
String s = atClass.value();
if (rawUrl.toString().endsWith("/") ){
rawUrl.append(s.startsWith("/") ? s.substring(1) : s);
} else {
rawUrl.append(s.startsWith("/") ? s : "/" + s);
}
} else {
final Path atDeclaringClass = method.getDeclaringClass().getAnnotation(Path.class);
if (atDeclaringClass != null) {
Expand All @@ -233,11 +238,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl

final Path atMethod = method.getAnnotation(Path.class);
if (atMethod != null) {
String value = atMethod.value();
if (rawUrl.toString().endsWith( "/" ) && value.startsWith( "/" )) {
value = value.substring( 1 );
String s = atMethod.value();
if (rawUrl.toString().endsWith("/") ){
rawUrl.append(s.startsWith("/") ? s.substring(1) : s);
} else {
rawUrl.append(s.startsWith("/") ? s : "/" + s);
}
rawUrl.append(value);
}

if (rawUrl.toString().trim().length() == 0) {
Expand Down

0 comments on commit ee04f6d

Please sign in to comment.