File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/test/java/org/jsoup/nodes Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -838,4 +838,16 @@ public void testHashAndEquals() {
838
838
assertFalse (e0 .hashCode () == (e6 ).hashCode ());
839
839
assertFalse (e0 .hashCode () == (e7 ).hashCode ());
840
840
}
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
+ }
841
853
}
You can’t perform that action at this time.
0 commit comments