* the absolute IRI.
*
* @return the relative IRI if relative to base, otherwise the absolute IRI.
*/
private static String removeBase(Object baseobj, String iri) {
JsonLdUrl base;
if (isString(baseobj)) {
base = JsonLdUrl.parse((String) baseobj);
} else {
base = (JsonLdUrl) baseobj;
}
// establish base root
String root = "";
if (!"".equals(base.href)) {
root += (base.protocol) + "//" + base.authority;
}
// support network-path reference with empty base
else if (iri.indexOf("//") != 0) {
root += "//";
}
// IRI not relative to base
if (iri.indexOf(root) != 0) {
return iri;
}
// remove root from IRI and parse remainder
final JsonLdUrl rel = JsonLdUrl.parse(iri.substring(root.length()));
// remove path segments that match
final List<String> baseSegments = _split(base.normalizedPath, "/");
final List<String> iriSegments = _split(rel.normalizedPath, "/");