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:
parent
bf95592b2c
commit
4e96caa623
@ -163,11 +163,21 @@ public final class Util {
|
||||
if (stringUri == null) {
|
||||
return baseUri;
|
||||
}
|
||||
Uri uri = Uri.parse(stringUri);
|
||||
if (!uri.isAbsolute() && baseUri != null) {
|
||||
uri = Uri.withAppendedPath(baseUri, stringUri);
|
||||
if (baseUri == null) {
|
||||
return Uri.parse(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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user