Skip to content

Commit cca1454

Browse files
Commit missing files during merge
1 parent 687b332 commit cca1454

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

packages/go_router/lib/src/information_provider.dart

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -178,33 +178,6 @@ class GoRouteInformationProvider extends RouteInformationProvider
178178
);
179179
}
180180

181-
/// Relatively go to [relativeLocation].
182-
void goRelative(String relativeLocation, {Object? extra}) {
183-
assert(
184-
!relativeLocation.startsWith('/'),
185-
"Relative locations must not start with a '/'.",
186-
);
187-
188-
final Uri currentUri = value.uri;
189-
Uri newUri = Uri.parse(
190-
currentUri.path.endsWith('/')
191-
? '${currentUri.path}$relativeLocation'
192-
: '${currentUri.path}/$relativeLocation',
193-
);
194-
newUri = newUri.replace(queryParameters: <String, dynamic>{
195-
...currentUri.queryParameters,
196-
...newUri.queryParameters,
197-
});
198-
199-
_setValue(
200-
newUri.toString(),
201-
RouteInformationState<void>(
202-
extra: extra,
203-
type: NavigatingType.go,
204-
),
205-
);
206-
}
207-
208181
/// Restores the current route matches with the `matchList`.
209182
void restore(String location, {required RouteMatchList matchList}) {
210183
_setValue(

packages/go_router/lib/src/path_utils.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,21 @@ String concatenatePaths(String parentPath, String childPath) {
119119
return '${parentPath == '/' ? '' : parentPath}/$childPath';
120120
}
121121

122+
/// Concatenates two Uri. It will [concatenatePaths] the parent's and the child's paths , then merges their query parameters.
123+
///
124+
/// e.g: pathA = /a?fid=f1, pathB = c/d?pid=p2, concatenatePaths(pathA, pathB) = /a/c/d?fid=1&pid=2.
125+
Uri concatenateUris(Uri parentUri, Uri childUri) {
126+
final Uri newUri = parentUri.replace(
127+
path: concatenatePaths(parentUri.path, childUri.path),
128+
queryParameters: <String, dynamic>{
129+
...parentUri.queryParameters,
130+
...childUri.queryParameters,
131+
},
132+
);
133+
134+
return newUri;
135+
}
136+
122137
/// Normalizes the location string.
123138
String canonicalUri(String loc) {
124139
if (loc.isEmpty) {

0 commit comments

Comments
 (0)