Browse Source

refactor(neon): Simplify completing URLs using the server URL

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/970/head
jld3103 1 year ago
parent
commit
2aa44fe074
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 12
      packages/neon/neon/lib/src/models/account.dart

12
packages/neon/neon/lib/src/models/account.dart

@ -95,13 +95,11 @@ class Account implements Credentials {
/// The paths of the [serverURL] and the [uri] need to be join to get the full path, unless the [uri] path is already an absolute path. /// The paths of the [serverURL] and the [uri] need to be join to get the full path, unless the [uri] path is already an absolute path.
/// In that case an instance hosted at a sub folder will already contain the sub folder part in the [uri]. /// In that case an instance hosted at a sub folder will already contain the sub folder part in the [uri].
Uri completeUri(final Uri uri) { Uri completeUri(final Uri uri) {
final result = serverURL.replace( final result = serverURL.resolveUri(uri);
queryParameters: uri.queryParameters, if (!uri.hasAbsolutePath) {
fragment: uri.fragment, return result.replace(path: '${serverURL.path}/${uri.path}');
); }
return result.replace( return result;
path: uri.hasAbsolutePath ? uri.path : '${result.path}/${uri.path}',
);
} }
/// Removes the [serverURL] part from the [uri]. /// Removes the [serverURL] part from the [uri].

Loading…
Cancel
Save