Feature: Convert username/email to lower case
Change-Id: I2614c3f84dc7a64d9cf66dad3e8db9bd6cfada35
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 7e718ef..fafa92e 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
@@ -41,6 +41,7 @@
private String externalAvatarUrl;
private String avatarChangeUrl;
private String sizeParameter;
+ private boolean lowerCase;
@Inject
ExternalUrlAvatarProvider(PluginConfigFactory cfgFactory,
@@ -51,6 +52,7 @@
externalAvatarUrl = cfg.getString("url");
avatarChangeUrl = cfg.getString("changeUrl");
sizeParameter = cfg.getString("sizeParameter");
+ lowerCase = cfg.getBoolean("lowerCase", false);
ssl = canonicalUrl != null && canonicalUrl.startsWith("https://");
}
@@ -118,6 +120,9 @@
|| !url.contains(placeholder)) {
return url;
}
+ if (lowerCase) {
+ replacement = replacement.toLowerCase();
+ }
// as we can't assume anything of 'replacement', we're URL encoding it
return url.replace(placeholder, Url.encode(replacement));
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 83ab4e7..0a61965 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -9,6 +9,7 @@
url = http://example.org/avatars/${user}.jpg
changeUrl = http://example.org/account.html
sizeParameter = s=${size}x${size}
+ lowerCase = true
```
<a id="url">
@@ -29,5 +30,9 @@
: URL parameter with `${size}` placeholder to forward the preferred
image size to the avatar provider. Optional.
+<a id="lowerCase">
+`plugin.@PLUGIN@.lowerCase`
+: Convert the username and email to lower case. Default value = false. Optional.
+
Please note that `http://` URLs will be automatically rewritten to
`https://`, if `gerrit.canonicalWebUrl` uses HTTPS.