Skip to content

Commit

Permalink
fix: empty calendar (#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
limwa committed Sep 20, 2024
2 parents ef5d4ce + 5515d1d commit 8f38a64
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
9 changes: 2 additions & 7 deletions packages/uni_app/lib/app_links/uni_app_links.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import 'dart:async';

import 'package:app_links/app_links.dart';
import 'package:uni/utils/uri.dart';

final _authUri = Uri(scheme: 'pt.up.fe.ni.uni', host: 'auth');

extension _StripQueryParameters on Uri {
Uri stripQueryParameters() {
return Uri(scheme: scheme, host: host, path: path);
}
}

class UniAppLinks {
final login = _AuthenticationAppLink(
redirectUri: _authUri.replace(path: '/login'),
Expand All @@ -30,7 +25,7 @@ class _AuthenticationAppLink {
FutureOr<void> Function(Uri redirectUri) callback,
) async {
final interceptedUri = _appLinks.uriLinkStream
.firstWhere((uri) => redirectUri == uri.stripQueryParameters());
.firstWhere((uri) => redirectUri == uri.stripQueryComponent());

await callback(redirectUri);
final data = await interceptedUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:uni/http/client/authenticated.dart';
import 'package:uni/http/client/timeout.dart';
import 'package:uni/session/authentication_controller.dart';
import 'package:uni/session/flows/base/session.dart';
import 'package:uni/utils/uri.dart';

extension UriString on String {
/// Converts a [String] to an [Uri].
Expand Down Expand Up @@ -65,6 +66,10 @@ class NetworkRouter {
];
}

return client.get(parsedUrl.replace(queryParameters: allQueryParameters));
final requestUri = parsedUrl
.replace(queryParameters: allQueryParameters)
.normalizeQueryComponent();

return client.get(requestUri);
}
}
16 changes: 16 additions & 0 deletions packages/uni_app/lib/utils/uri.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extension UriUtils on Uri {
Uri stripQueryComponent() {
return Uri(
scheme: scheme,
userInfo: userInfo,
host: host,
port: port,
path: path,
fragment: fragment.isNotEmpty ? fragment : null,
);
}

Uri normalizeQueryComponent() => query.isNotEmpty
? replace(query: query.replaceAll('+', '%20'))
: stripQueryComponent();
}

0 comments on commit 8f38a64

Please sign in to comment.