2222import java .util .StringJoiner ;
2323
2424/**
25- * More algorithms on IRI3986's.
26- * The various forms of relativizing IRIs.
25+ * More relativization algorithms on IRI3986's.
2726 */
2827public class AlgRelativizeIRI {
2928
30- // For compatibility with jena-iri ...
31- // relativeScheme: when only the scheme with no "//", then NETWORK does not abbreviate.
32- // Strict, illegal because if there is a scheme, there must be //
33- /*package*/ static final boolean legacyCompatibility = false ;
34-
3529 /**
3630 * Calculate a "same scheme" relative URI, if possible.
3731 * <p>
@@ -43,8 +37,7 @@ public static IRI3986 relativeScheme(IRI base, IRI target) {
4337 return null ;
4438 if ( ! Objects .equals (base .scheme (), target .scheme ()) )
4539 return null ;
46- if ( legacyCompatibility && ! base .hasAuthority () && base .path ().isEmpty () )
47- return IRI3986 .build (null , "" , target .path (), target .query (), target .fragment ());
40+ // No scheme.
4841 return IRI3986 .build (null , target .authority (), target .path (), target .query (), target .fragment ());
4942 }
5043
@@ -65,18 +58,6 @@ public static IRI3986 relativeResource(IRI base, IRI target) {
6558 return IRI3986 .build (null , null , target .path (), target .query (), target .fragment ());
6659 }
6760
68- /**
69- * Calculate a relative URI as a absolute path, if possible.
70- * <p>
71- * That is, the IRIs have the same scheme and authority.
72- * The base does not have a query string.
73- * The relative URI is the path, query and fragment of the target.
74- */
75- public static IRI3986 relativeAbsolutePath (IRI base , IRI target ) {
76- // Same as relativeLocalResource, using jena-iri naming.
77- return relativeResource (base , target );
78- }
79-
8061 /**
8162 * Calculate a "same document" relative URI, if possible.
8263 * <p>
@@ -138,23 +119,11 @@ public static IRI3986 relativePath(IRI base, IRI target) {
138119 return IRI3986 .build (null , null , x , target .query (), target .fragment ());
139120 }
140121
141- if ( legacyCompatibility ) {
142- // Same path, no target query.
143- // This would be just a #frag which is "same document".
144- // For compatibility with jena-iri ...
145- String pathRel = lastSegment (targetPath );
146- if ( pathRel .isEmpty () )
147- pathRel = "." ;
148- return IRI3986 .build (null , null , pathRel , null , target .fragment ());
149- } else {
150- String pathRel = targetPath .endsWith ("/" ) ?
151- // Both "" and "." are possible when the two paths end "/".
152- "." : "" ;
153- return IRI3986 .build (null , null , pathRel , null , target .fragment ());
154- }
122+ // Both "" and "." are possible when the two paths end "/".
123+ String pathRel = targetPath .endsWith ("/" ) ? "." : "" ;
124+ return IRI3986 .build (null , null , pathRel , null , target .fragment ());
155125 }
156126
157-
158127 String relPath = relativeChildPath (basePath , targetPath );
159128 if ( relPath == null )
160129 return null ;
0 commit comments