Skip to content

Commit

Permalink
Tidy AlgResolveIRI
Browse files Browse the repository at this point in the history
afs committed Oct 28, 2024
1 parent 379e095 commit 3145727
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions iri4ld/src/main/java/org/seaborne/rfc3986/AlgResolveIRI.java
Original file line number Diff line number Diff line change
@@ -34,19 +34,24 @@ public static IRI3986 resolve(IRI base, IRI reference) {
return transformReferencesNonStrict(reference, base);
}

/** 5.2.2. Transform References
/**
* 5.2.2. Transform References
* <p>
* <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.2">RFC 3986 section 5.2.2</a>.
* <p>
* "A non-strict parser" - this resolves (hosts and) paths if the reference and the base have the same scheme.
*/
private static IRI3986 transformReferencesStrict(IRI reference, IRI base) {
boolean sameScheme = Objects.equals(reference.scheme(), base.scheme());
if ( reference.hasScheme() )
return RFC3986.create(reference);
return transformReferencesNonStrict(reference, base);
}

/**
* 5.2.2. Transform References
* <p>
* <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.2">RFC 3986 section 5.2.2</a>.
* <p>
* "A non-strict parser" - this resolves (hosts and) paths if the reference and the base have the same scheme.
*/
private static IRI3986 transformReferencesNonStrict(IRI reference, IRI base) {
// Note the argument order is reverse from "resolve(base, relative)" to be more like RFC 3986.
String t_scheme = null;
@@ -195,8 +200,6 @@ static String remove_dot_segments(String path) {
trailingSlash = true;
else if ( path.charAt(path.length()-1) == '/' )
trailingSlash = true;
// else if ( path.equals("..") )
// trailingSlash = true;
}

for ( int j = 0 ; j < N ; j++ ) {
@@ -257,7 +260,7 @@ public static IRI3986 relativize(IRI base, IRI iri) {
return null;
if ( ! Objects.equals(iri.authority(), base.authority()) )
return null;
// Authority covers host and port checks.
// Authority covers host and port
// if ( ! Objects.equals(base.getHost(), this.getHost()) )
// return null;
// if ( ! Objects.equals(base.getPort(), this.getPort()) )

0 comments on commit 3145727

Please sign in to comment.