OSDN Git Service

deal with url end with '/' problems
authorsuccessli <successli@outlook.com>
Fri, 1 Jun 2018 02:48:48 +0000 (10:48 +0800)
committersuccessli <successli@outlook.com>
Fri, 1 Jun 2018 02:48:48 +0000 (10:48 +0800)
src/main/java/io/bytom/http/Client.java
src/test/java/io/bytom/TestUtils.java

index a0bb7e8..03b7b34 100644 (file)
@@ -66,6 +66,11 @@ public class Client {
             coreURL = "http://127.0.0.1:9888";
         }
 
+        if (coreURL.endsWith("/")) {
+            //split the last char "/"
+            coreURL = coreURL.substring(0, coreURL.length()-1);
+        }
+
         return new Client(coreURL, accessToken);
     }
 
index e4ac7f2..7d40cfc 100644 (file)
@@ -3,17 +3,14 @@ package io.bytom;
 import io.bytom.common.Configuration;
 import io.bytom.exception.BytomException;
 import io.bytom.http.Client;
+import org.apache.log4j.Logger;
 
 /**
  * TestUtils provides a simplified api for testing.
  */
 public class TestUtils {
-    public static Client generateClient_old() throws BytomException {
 
-        String coreURL = "http://127.0.0.1:9888";
-
-        return new Client(coreURL);
-    }
+    public static Logger logger = Logger.getLogger(TestUtils.class);
 
     public static Client generateClient() throws BytomException {
 
@@ -24,6 +21,11 @@ public class TestUtils {
             coreURL = "http://127.0.0.1:9888";
         }
 
+        if (coreURL.endsWith("/")) {
+            //split the last char "/"
+            coreURL = coreURL.substring(0, coreURL.length()-1);
+        }
+
         return new Client(coreURL, accessToken);
     }
 }