Skip to content

Commit 84a2dfe

Browse files
committed
Added test to confirm that jhy#345 (abs urls) work
1 parent 3b4f9df commit 84a2dfe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/java/org/jsoup/nodes/ElementTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,4 +838,16 @@ public void testHashAndEquals() {
838838
assertFalse(e0.hashCode() == (e6).hashCode());
839839
assertFalse(e0.hashCode() == (e7).hashCode());
840840
}
841+
842+
@Test public void testRelativeUrls() {
843+
String html = "<body><a href='./one.html'>One</a> <a href='two.html'>two</a> <a href='../three.html'>Three</a> <a href='//example2.com/four/'>Four</a> <a href='https://example2.com/five/'>Five</a>";
844+
Document doc = Jsoup.parse(html, "http://example.com/bar/");
845+
Elements els = doc.select("a");
846+
847+
assertEquals("http://example.com/bar/one.html", els.get(0).absUrl("href"));
848+
assertEquals("http://example.com/bar/two.html", els.get(1).absUrl("href"));
849+
assertEquals("http://example.com/three.html", els.get(2).absUrl("href"));
850+
assertEquals("http://example2.com/four/", els.get(3).absUrl("href"));
851+
assertEquals("https://example2.com/five/", els.get(4).absUrl("href"));
852+
}
841853
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy