URI("http://www.example.com:8080/dir/file#abcd").relativeTo('http://www.example.com:8080/dir/file').toString() returns ./file#abcd ('#abcd' would have been better) The more-optimal result seems to work with absoluteTo: URI("#abcd").absoluteTo('http://www.example.com:8080/dir/file').toString() returns "http://www.example.com:8080/dir/file#abcd" Great library, btw!