mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 10:28:50 +01:00
Fix api request to server under subdir
This commit is contained in:
parent
7e120295b9
commit
fd4b6712ef
1 changed files with 14 additions and 6 deletions
|
@ -48,12 +48,7 @@ class Api {
|
|||
Uint8List bodyBytes,
|
||||
bool isResponseString = true,
|
||||
}) async {
|
||||
Uri url;
|
||||
if (_account.scheme == "http") {
|
||||
url = Uri.http(_account.address, endpoint);
|
||||
} else {
|
||||
url = Uri.https(_account.address, endpoint);
|
||||
}
|
||||
final url = _makeUri(endpoint);
|
||||
final req = http.Request(method, url)
|
||||
..headers.addAll({
|
||||
"authorization": getAuthorizationHeaderValue(_account),
|
||||
|
@ -87,6 +82,19 @@ class Api {
|
|||
isResponseString ? response.body : response.bodyBytes);
|
||||
}
|
||||
|
||||
Uri _makeUri(String endpoint) {
|
||||
final splits = _account.address.split("/");
|
||||
final authority = splits[0];
|
||||
final path = splits.length > 1
|
||||
? splits.sublist(1).join("/") + "/$endpoint"
|
||||
: endpoint;
|
||||
if (_account.scheme == "http") {
|
||||
return Uri.http(authority, path);
|
||||
} else {
|
||||
return Uri.https(authority, path);
|
||||
}
|
||||
}
|
||||
|
||||
final Account _account;
|
||||
|
||||
static final _log = Logger("api.api.Api");
|
||||
|
|
Loading…
Reference in a new issue