Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/go_router_builder/lib/src/route_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ mixin _GoRouteMixin on RouteBaseConfig {
return MapEntry<String, String>(pathParameter, valueBuffer.toString());
}),
);
final String location = patternToPath(_basePathForLocation, pathParameters);
final String location = patternToPath(Uri.encodeFull(_basePathForLocation), pathParameters);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using Uri.encodeFull is an improvement for paths with spaces, but it's not a complete solution. It doesn't encode other characters that should be percent-encoded in a path segment (like +), which can lead to malformed or ambiguous URLs.

A more robust approach is to split the path into segments, encode each static segment individually, and then rejoin them. This ensures that all special characters in static path segments are correctly encoded, while parameter placeholders are preserved for patternToPath.

Suggested change
final String location = patternToPath(Uri.encodeFull(_basePathForLocation), pathParameters);
final String location = patternToPath(_basePathForLocation.split('/').map((String s) => s.startsWith(':') ? s : Uri.encodeComponent(s)).join('/'), pathParameters);

return "'$location'";
}

Expand Down