Skip to content

Commit ca82aec

Browse files
committed
Add unit test for // requirement for HTTP
The HTTP protocol mandates the `//` that's not mandatory in URIs. To prevent false positives, a unit test is added that verifies that `//` is used in HTTP-based links.
1 parent 0f56a1b commit ca82aec

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/test/java/nl/goodbytes/util/linkdetector/LinkDetectorTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ public void testCaseSensitivity() throws Exception
103103
assertTrue(fragments.get(0).isLink());
104104
}
105105

106+
@Test
107+
public void testRequiredDoubleSlash() throws Exception
108+
{
109+
// Setup test fixture.
110+
final String input = "https:www.example.org";
111+
112+
// Execute system under test.
113+
final List<Fragment> fragments = LinkDetector.parse(input);
114+
115+
// Verify results.
116+
assertEquals(1, fragments.size());
117+
assertEquals(0, fragments.get(0).startIndex());
118+
assertEquals(input.length(), fragments.get(0).endIndex());
119+
assertEquals(input, fragments.get(0).toString());
120+
assertFalse(fragments.get(0).isLink());
121+
}
122+
106123
@Test
107124
public void testEmbeddedLink() throws Exception
108125
{

0 commit comments

Comments
 (0)