Add the GWT hash separator to the GWT url
It was removed by mistake in d5b401672bc69b3f7a861fd4572b988289d20c0b,
making the GWT redirects loop forever (by forwarding /c/ to /c/)
So when forwarding PolyGerrit URLs to their respective GWT equivalents,
make sure to add the GWT hash separator. Default to not doing it.
Bug: Issue 9410
Change-Id: Ic687e1c87b0f321a56ce1e08bec7beb82ea64cb1
diff --git a/java/com/google/gerrit/httpd/UrlModule.java b/java/com/google/gerrit/httpd/UrlModule.java
index 1dd176a..94855b9 100644
--- a/java/com/google/gerrit/httpd/UrlModule.java
+++ b/java/com/google/gerrit/httpd/UrlModule.java
@@ -134,7 +134,8 @@
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
- toGerrit(req.getRequestURI().substring(req.getContextPath().length()), req, rsp);
+ String path = req.getRequestURI().substring(req.getContextPath().length());
+ toGerrit(path, req, rsp, true);
}
});
}
@@ -276,8 +277,16 @@
static void toGerrit(String target, HttpServletRequest req, HttpServletResponse rsp)
throws IOException {
+ toGerrit(target, req, rsp, false);
+ }
+
+ static void toGerrit(String target, HttpServletRequest req, HttpServletResponse rsp, boolean gwt)
+ throws IOException {
final StringBuilder url = new StringBuilder();
url.append(req.getContextPath());
+ if (gwt) {
+ url.append("/#");
+ }
url.append(target);
rsp.sendRedirect(url.toString());
}