Browse Source

IrcAddress now parses the query and fragment parts of URIs

Fixes issue 944
Added unit test to test behaviour described in 944

git-svn-id: http://svn.dmdirc.com/trunk@3560 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 years ago
parent
commit
e460dddf94
2 changed files with 16 additions and 3 deletions
  1. 3
    1
      src/com/dmdirc/util/IrcAddress.java
  2. 13
    2
      test/com/dmdirc/util/IrcAddressTest.java

+ 3
- 1
src/com/dmdirc/util/IrcAddress.java View File

@@ -91,7 +91,9 @@ public class IrcAddress implements Serializable {
91 91
             doPass(uri.getUserInfo());
92 92
         }
93 93
         
94
-        doChannels(uri.getPath());
94
+        doChannels(uri.getPath() + (uri.getQuery() == null ? "" :
95
+            "?" + uri.getQuery()) + (uri.getFragment() == null ? "" :
96
+            "#" + uri.getFragment()));
95 97
 
96 98
         if (uri.getPort() > -1) {
97 99
             doPort(uri.getPort());

+ 13
- 2
test/com/dmdirc/util/IrcAddressTest.java View File

@@ -179,7 +179,18 @@ public class IrcAddressTest extends junit.framework.TestCase {
179 179
             assertFalse(true);
180 180
         }
181 181
     }
182
-    
182
+
183
+    @Test
184
+    public void testChannels() throws InvalidAddressException {
185
+        try {
186
+            final IrcAddress address3 = new IrcAddress("irc://server/#MDbot");
187
+            assertEquals(1, address3.getChannels().size());
188
+            assertEquals("#MDbot", address3.getChannels().get(0));
189
+        } catch (InvalidAddressException ex) {
190
+            fail();
191
+        }
192
+    }
193
+
183 194
     @Test
184 195
     public void testEncoding() {
185 196
         try {
@@ -188,7 +199,7 @@ public class IrcAddressTest extends junit.framework.TestCase {
188 199
             assertEquals("#DMDirc", address1.getChannels().get(0));
189 200
         } catch (InvalidAddressException ex) {
190 201
             assertFalse(true);
191
-        }        
202
+        }
192 203
     }
193 204
 
194 205
 }

Loading…
Cancel
Save