My goal is to follow the term of absolute-URI = scheme ":" hier-part [ "?" query ] from Appendix A. Collected ABNF for URI from [RFC3986]
My understanding that is absolute-uri can't have fragment. I tested it with java.net.URI. I checked that isAbsolute() method only check for the scheme != null instead of checking the entire String.
My expected result was that the URI's isAbsolute() method return:
- false for Uri
http://wwww.example.com/index.html#Relatedbecause it has fragment. - true for Uri
http://www.example.com/index.html.
My actual result was that the URI's isAbsolute() method return true.
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.net.URI;
import java.net.URISyntaxException;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class RegExTest {
@Test
void validAbsoluteUri() throws URISyntaxException {
URI uri1 = new URI("http://www.example.com/index.html#Related");
Assertions.assertEquals(false, uri1.isAbsolute());
}
}