Merge "Assume correct relative or absolute URL from Weblink provider" into stable-2.14
This commit is contained in:
@@ -35,6 +35,8 @@ import com.google.gerrit.extensions.webui.TagWebLink;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -179,7 +181,11 @@ public class GitwebConfig {
|
||||
private final GitwebType type;
|
||||
|
||||
@Inject
|
||||
GitwebConfig(GitwebCgiConfig cgiConfig, @GerritServerConfig Config cfg) {
|
||||
GitwebConfig(
|
||||
GitwebCgiConfig cgiConfig,
|
||||
@GerritServerConfig Config cfg,
|
||||
@Nullable @CanonicalWebUrl String gerritUrl)
|
||||
throws MalformedURLException {
|
||||
if (isDisabled(cfg)) {
|
||||
type = null;
|
||||
url = null;
|
||||
@@ -192,7 +198,14 @@ public class GitwebConfig {
|
||||
// Use an externally managed gitweb instance, and not an internal one.
|
||||
url = cfgUrl;
|
||||
} else {
|
||||
url = firstNonNull(cfgUrl, "gitweb");
|
||||
String baseGerritUrl;
|
||||
if (gerritUrl != null) {
|
||||
URL u = new URL(gerritUrl);
|
||||
baseGerritUrl = u.getPath();
|
||||
} else {
|
||||
baseGerritUrl = "/";
|
||||
}
|
||||
url = firstNonNull(cfgUrl, baseGerritUrl + "gitweb");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^https?\:\/\//.test(webLink)) {
|
||||
webLink = '../../' + webLink;
|
||||
}
|
||||
|
||||
return webLink;
|
||||
},
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ limitations under the License.
|
||||
assert.isOk(element._computeShowWebLink(element.change,
|
||||
element.commitInfo, element.serverConfig));
|
||||
assert.equal(element._computeWebLink(element.change, element.commitInfo,
|
||||
element.serverConfig), '../../link-url');
|
||||
element.serverConfig), 'link-url');
|
||||
});
|
||||
|
||||
test('does not relativize web links that begin with scheme', function() {
|
||||
|
||||
Reference in New Issue
Block a user