diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 83b5e7b95c..63854dc713 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -75,7 +75,7 @@ public class RemoteEnvPane extends BasicBeanPane { private UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK")); private UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); private UILabel uiLabel = new UILabel(); - private String IPV6_JUDGE_SYMBOL = "["; + private static final String IPV6_JUDGE_SYMBOL = "["; /** * 是否启用 https 勾选框 @@ -210,6 +210,9 @@ public class RemoteEnvPane extends BasicBeanPane { private void actionURLInputChange() { remoteWorkspaceURL = new RemoteWorkspaceURL(remoteEnvURLInput.getText()); + if (remoteWorkspaceURL.getURL().contains(IPV6_JUDGE_SYMBOL)) { + remoteWorkspaceURL.refreshIPV6Format(); + } fillIndividualField(); httpsCheckbox.setSelected(remoteWorkspaceURL.getHttps()); diff --git a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java index b37bc4d051..15e1674b11 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java +++ b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java @@ -1,9 +1,15 @@ package com.fr.env; +import com.fr.log.FineLoggerFactory; import com.fr.stable.AssistUtils; import com.fr.stable.FCloneable; import com.fr.stable.StringUtils; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; + /** * @author yaohwu */ @@ -135,24 +141,13 @@ public class RemoteWorkspaceURL implements FCloneable { */ public void refreshIPV6Format() { String url = this.url; - // 第三次出现"/"的地方 - int webIndex = url.indexOf("/", url.indexOf("://") + 3); - int hostIndex = url.indexOf("["); - int portIndex = url.indexOf("]"); - isContainsRelatedIndex(webIndex, hostIndex, portIndex); - this.host = url.substring(hostIndex, portIndex + 1); - this.port = url.substring(portIndex + 2, webIndex); - } - - /** - * - * @param webIndex web指针 - * @param hostIndex 主机指针 - * @param portIndex 端口指针 - * @return 三个指针是否都存在 - */ - public boolean isContainsRelatedIndex(int webIndex, int hostIndex, int portIndex) { - return webIndex != -1 && hostIndex != -1 && portIndex != -1; + try { + URI uri = new URI(url); + this.host = uri.getHost(); + this.port = String.valueOf(uri.getPort()); + } catch (URISyntaxException e) { + FineLoggerFactory.getLogger().info("error request url"); + } } public void setHttps(boolean https) { @@ -255,4 +250,5 @@ public class RemoteWorkspaceURL implements FCloneable { } } } + } \ No newline at end of file