【发布时间】:2021-07-12 18:27:54
【问题描述】:
我的目标是遵循附录 A 中的 absolute-URI = scheme ":" hier-part [ "?" query ] 术语。从 [RFC3986] 中收集的 URI ABNF
我的理解是absolute-uri 不能有fragment。我用java.net.URI 对其进行了测试。我检查了isAbsolute() method 只检查方案!= null 而不是检查整个字符串。
我的预期结果是 URI 的 isAbsolute() 方法返回:
- Uri
http://wwww.example.com/index.html#Related为 false,因为它有片段。 - Uri
http://www.example.com/index.html为真。
我的实际结果是 URI 的 isAbsolute() 方法返回 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());
}
}
【问题讨论】: