Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra whitespace when parsing search inputs. #8466

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AppEngine version, listed here to ease deployment and troubleshooting.
## Next Release (replace with git tag when deployed)
* Bump runtimeVersion to `2025.01.15`.
* Note: started deleting `Package.isBlocked`, `Publisher.isBlocked`, `User.isBlocked`.
* Note: Updates search form normalization: whitespaces.

## `20250114t095800-all`
* Bump runtimeVersion to `2025.01.14`.
Expand Down
2 changes: 1 addition & 1 deletion pkg/_pub_shared/lib/search/search_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class SearchForm {
}) {
currentPage ??= 1;
pageSize ??= resultsPerPage;
final q = _stringToNull(query?.trim());
final q = _stringToNull(query?.replaceAll(_whitespacesRegExp, ' ').trim());
return SearchForm._(
query: q,
order: order,
Expand Down
5 changes: 5 additions & 0 deletions pkg/_pub_shared/test/search/search_form_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ void main() {
expect(form.toSearchLink(page: 3), '/packages?q=web+framework&page=3');
});

test('query with extra whitespaces', () {
final form = SearchForm(query: ' aa bbb cc ');
expect(form.query, 'aa bbb cc');
});

test('query with sdk context', () {
final form = SearchForm(query: 'sdk:flutter some framework');
expect(form.toSearchLink(), '/packages?q=sdk%3Aflutter+some+framework');
Expand Down
Loading