TF-3260 Load & Display App Grid Linagora Ecosystem
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:core/data/constants/constant.dart';
|
||||
import 'package:core/data/model/query/query_parameter.dart';
|
||||
import 'package:core/data/network/config/service_path.dart';
|
||||
|
||||
@@ -7,24 +8,32 @@ extension ServicePathExtension on ServicePath {
|
||||
return path;
|
||||
}
|
||||
|
||||
ServicePath generateOIDCPath(Uri baseUrl) {
|
||||
return ServicePath(baseUrl.toString() + path);
|
||||
ServicePath usingBaseUrl(String baseUrl) {
|
||||
String normalizedBaseUrl = baseUrl.endsWith(Constant.slashCharacter)
|
||||
? baseUrl.substring(0, baseUrl.length - 1)
|
||||
: baseUrl;
|
||||
|
||||
String normalizedPath = path.startsWith(Constant.slashCharacter)
|
||||
? path.substring(1)
|
||||
: path;
|
||||
|
||||
return ServicePath('$normalizedBaseUrl${Constant.slashCharacter}$normalizedPath');
|
||||
}
|
||||
|
||||
ServicePath withQueryParameters(List<QueryParameter> queryParameters) {
|
||||
if (queryParameters.isEmpty) {
|
||||
return this;
|
||||
}
|
||||
if (path.lastIndexOf('/') == path.length - 1) {
|
||||
if (path.lastIndexOf(Constant.slashCharacter) == path.length - 1) {
|
||||
final newPath = path.substring(0, path.length - 1);
|
||||
|
||||
return ServicePath('$newPath?${queryParameters
|
||||
.map((query) => '${query.queryName}=${query.queryValue}')
|
||||
.join('&')}');
|
||||
.join(Constant.andCharacter)}');
|
||||
} else {
|
||||
return ServicePath('$path?${queryParameters
|
||||
.map((query) => '${query.queryName}=${query.queryValue}')
|
||||
.join('&')}');
|
||||
.join(Constant.andCharacter)}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +42,10 @@ extension ServicePathExtension on ServicePath {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (path.lastIndexOf('/') == path.length - 1) {
|
||||
if (path.lastIndexOf(Constant.slashCharacter) == path.length - 1) {
|
||||
return ServicePath('$path$pathParameter');
|
||||
} else {
|
||||
return ServicePath('$path/$pathParameter');
|
||||
return ServicePath('$path${Constant.slashCharacter}$pathParameter');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:core/data/network/config/service_path.dart';
|
||||
|
||||
class Endpoint {
|
||||
static final ServicePath webFinger = ServicePath('/.well-known/webfinger');
|
||||
static final ServicePath webFinger = ServicePath('.well-known/webfinger');
|
||||
static final ServicePath linagoraEcosystem = ServicePath('.well-known/linagora-ecosystem');
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class OIDCHttpClient {
|
||||
try {
|
||||
final result = await _dioClient.get(
|
||||
Endpoint.webFinger
|
||||
.generateOIDCPath(Uri.parse(oidcRequest.baseUrl))
|
||||
.usingBaseUrl(oidcRequest.baseUrl)
|
||||
.withQueryParameters([
|
||||
StringQueryParameter('resource', oidcRequest.resourceUrl),
|
||||
StringQueryParameter('rel', OIDCRequest.relUrl),
|
||||
|
||||
Reference in New Issue
Block a user