Merge changes Icca726b5,I91cf6da1,Iea3ba2aa
* changes:
Add new concept topic, Patch Sets, to documentation
Add new concept topic on refs/for namespace
Add new topic, Changes, to documentation
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java
index 107f584..db0212e 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java
@@ -17,6 +17,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.servlet.http.HttpServletResponse.SC_OK;
+import com.google.common.base.Strings;
import com.google.common.io.Resources;
import com.google.gerrit.common.Nullable;
import com.google.template.soy.SoyFileSet;
@@ -61,6 +62,10 @@
}
static String computeCanonicalPath(String canonicalURL) throws URISyntaxException {
+ if (Strings.isNullOrEmpty(canonicalURL)) {
+ return "";
+ }
+
// If we serving from a sub-directory rather than root, determine the path
// from the cannonical web URL.
URI uri = new URI(canonicalURL);
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GetOAuthToken.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GetOAuthToken.java
index 1099d6b..587f268 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GetOAuthToken.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GetOAuthToken.java
@@ -38,7 +38,7 @@
private final Provider<CurrentUser> self;
private final OAuthTokenCache tokenCache;
- private final String hostName;
+ private final Provider<String> canonicalWebUrlProvider;
@Inject
GetOAuthToken(
@@ -47,7 +47,7 @@
@CanonicalWebUrl Provider<String> urlProvider) {
this.self = self;
this.tokenCache = tokenCache;
- this.hostName = getHostName(urlProvider.get());
+ this.canonicalWebUrlProvider = urlProvider;
}
@Override
@@ -63,7 +63,7 @@
}
OAuthTokenInfo accessTokenInfo = new OAuthTokenInfo();
accessTokenInfo.username = a.getUserName();
- accessTokenInfo.resourceHost = hostName;
+ accessTokenInfo.resourceHost = getHostName(canonicalWebUrlProvider.get());
accessTokenInfo.accessToken = accessToken.getToken();
accessTokenInfo.providerId = accessToken.getProviderId();
accessTokenInfo.expiresAt = Long.toString(accessToken.getExpiresAt());
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginLoader.java b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginLoader.java
index fcc6801..d972087 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginLoader.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginLoader.java
@@ -17,6 +17,7 @@
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -580,9 +581,14 @@
}
private String getPluginCanonicalWebUrl(String name) {
+ String canonicalWebUrl = urlProvider.get();
+ if (Strings.isNullOrEmpty(canonicalWebUrl)) {
+ return "/plugins/" + name;
+ }
+
String url =
String.format(
- "%s/plugins/%s/", CharMatcher.is('/').trimTrailingFrom(urlProvider.get()), name);
+ "%s/plugins/%s/", CharMatcher.is('/').trimTrailingFrom(canonicalWebUrl), name);
return url;
}