diff --git a/src/one/nio/net/ConnectionString.java b/src/one/nio/net/ConnectionString.java index 43387c9..93fe648 100755 --- a/src/one/nio/net/ConnectionString.java +++ b/src/one/nio/net/ConnectionString.java @@ -32,6 +32,31 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * Available HTTP params for configure directly in ConnectionString url: + * + */ public class ConnectionString { private static final Pattern INTERFACE_PATTERN = Pattern.compile("\\{(.+)\\}"); private static final Map WELL_KNOWN_PORTS = new HashMap<>(); diff --git a/test/one/nio/net/ConnectionStringTest.java b/test/one/nio/net/ConnectionStringTest.java index baf4ba2..24d59c0 100755 --- a/test/one/nio/net/ConnectionStringTest.java +++ b/test/one/nio/net/ConnectionStringTest.java @@ -49,6 +49,19 @@ public void testConnectionStrings() { assertEquals("?", conn.getStringParam("question")); assertEquals(345, conn.getIntParam("int", 0)); + conn = new ConnectionString("https://example.com?str=s&empty=&int=123"); + assertEquals("example.com", conn.getHost()); + assertEquals(443, conn.getPort()); + assertEquals("?str=s&empty=&int=123", conn.getPath()); + assertEquals("s", conn.getStringParam("str")); + assertEquals("", conn.getStringParam("empty", "def")); + assertEquals(123, conn.getIntParam("int", 0)); + + conn = new ConnectionString("https://example.com/somePath"); + assertEquals("example.com", conn.getHost()); + assertEquals(443, conn.getPort()); + assertEquals("/somePath", conn.getPath()); + conn = new ConnectionString("socket://[::1]:12345?:=true"); assertEquals("[::1]", conn.getHost()); assertEquals(12345, conn.getPort());