mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Prepend sever URL with "http://" if protocol was not specified
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.tasks.impl;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.PasswordUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.tasks.TaskRepository;
|
||||
import com.intellij.tasks.TaskRepositoryType;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
@@ -24,6 +25,8 @@ import com.intellij.util.xmlb.annotations.Transient;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -137,4 +140,25 @@ public abstract class BaseRepository extends TaskRepository {
|
||||
Matcher matcher = PATTERN.matcher(taskName);
|
||||
return matcher.find() ? matcher.group() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUrl(String url) {
|
||||
super.setUrl(addSchemeIfNoneSpecified(url));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String addSchemeIfNoneSpecified(@Nullable String url) {
|
||||
if (StringUtil.isNotEmpty(url)) {
|
||||
try {
|
||||
final String scheme = new URI(url).getScheme();
|
||||
// For URL like "foo.bar:8080" host name will be parsed as scheme
|
||||
if (scheme == null || !scheme.startsWith("http")) {
|
||||
url = "http://" + url;
|
||||
}
|
||||
}
|
||||
catch (URISyntaxException ignored) {
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,9 +130,6 @@ public class YouTrackRepository extends BaseRepositoryImpl {
|
||||
}
|
||||
|
||||
private HttpClient login(PostMethod method) throws Exception {
|
||||
if (method.getHostConfiguration().getProtocol() == null) {
|
||||
throw new Exception("Protocol not specified");
|
||||
}
|
||||
HttpClient client = getHttpClient();
|
||||
client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(getUsername(), getPassword()));
|
||||
configureHttpMethod(method);
|
||||
|
||||
Reference in New Issue
Block a user