Resolve reference Uris correctly.

Ignore the path of the base Uri if the reference starts with "/".
Spec - http://tools.ietf.org/html/rfc3986#section-5.2.2
This commit is contained in:
Oliver Woodman 2014-09-19 18:31:17 +01:00
parent bf95592b2c
commit 4e96caa623

View File

@ -163,11 +163,21 @@ public final class Util {
if (stringUri == null) { if (stringUri == null) {
return baseUri; return baseUri;
} }
Uri uri = Uri.parse(stringUri); if (baseUri == null) {
if (!uri.isAbsolute() && baseUri != null) { return Uri.parse(stringUri);
uri = Uri.withAppendedPath(baseUri, stringUri);
} }
return uri; if (stringUri.startsWith("/")) {
return new Uri.Builder()
.scheme(baseUri.getScheme())
.authority(baseUri.getAuthority())
.appendEncodedPath(stringUri)
.build();
}
Uri uri = Uri.parse(stringUri);
if (uri.isAbsolute()) {
return uri;
}
return Uri.withAppendedPath(baseUri, stringUri);
} }
/** /**