Support URLs with other parameters next to ${size}
The sizeParameter was just appended to the URL after a '?'.
This did not work when the URL itself already contained a '?'.
Now check for existing parameters and insert a '&' instead.
This way, we now support URLs of e.g.:
'/cgi-bin/avatar?uid=${user}&size=${size}'.
Change-Id: I10781a04eeec8bbe68451fab38942a0e305b27f4
diff --git a/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java b/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java
index c293ba7..ca5444f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java
@@ -85,7 +85,11 @@
avatarUrl.append(replaceInUrl(EMAIL_PLACEHOLDER, userReplacedAvatarURL,
forUser.getAccount().getPreferredEmail()));
if (imageSize > 0 && sizeParameter != null) {
- avatarUrl.append("?");
+ if (avatarUrl.indexOf("?") < 0) {
+ avatarUrl.append("?");
+ } else {
+ avatarUrl.append("&");
+ }
avatarUrl.append(sizeParameter.replaceAll("\\$\\{size\\}",
Integer.toString(imageSize)));
}