From 56839c3e4fbe051306807bb231aaccb01f871725 Mon Sep 17 00:00:00 2001 From: foxsofter Date: Wed, 5 Jun 2024 01:40:50 +0800 Subject: [PATCH] fix: url is missing / at the beginning --- CHANGELOG.md | 4 ++++ lib/src/navigator/navigator_route_settings.dart | 15 ++++++++++----- pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 547fbe5..66f4a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.15.2 + +- fix: url is missing / at the beginning + ## 4.15.1 - fix: push with innerURL not working diff --git a/lib/src/navigator/navigator_route_settings.dart b/lib/src/navigator/navigator_route_settings.dart index a45e728..0b0455e 100644 --- a/lib/src/navigator/navigator_route_settings.dart +++ b/lib/src/navigator/navigator_route_settings.dart @@ -165,12 +165,17 @@ extension NavigatorRouteSettings on RouteSettings { String get url { if (_urlOf[this] == null) { + var u = ''; final settingsName = name; - _urlOf[this] = settingsName == null || - settingsName.isEmpty || - !settingsName.contains(' ') - ? '' - : settingsName.split(' ').last; + if (settingsName != null && + settingsName.isNotEmpty && + settingsName.contains(' ')) { + u = settingsName.split(' ').last; + // 补充 / 使其成为正常的 url + if (!u.startsWith('/')) { + _urlOf[this] = '/$u'; + } + } } return _urlOf[this]!; } diff --git a/pubspec.yaml b/pubspec.yaml index ed93d52..f11b95b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_thrio description: Thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs. -version: 4.15.1 +version: 4.15.2 homepage: https://github.com/flutter-thrio/flutter_thrio environment: