Skip to content

Commit

Permalink
more tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Jan 31, 2025
1 parent 0d1bb11 commit 248b07d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/ada/url_search_params-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ inline void url_search_params::sort() {
return (codePoint1 < codePoint2);
}
}
return (i < lhs.first.size());
return (j < rhs.first.size() || low_surrogate2 != 0);
});
}

Expand Down
10 changes: 10 additions & 0 deletions tests/url_search_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,14 @@ TEST(url_search_params, sort_unicode_code_units) {
ASSERT_EQ(keys.next(), "\xf0\x9f\x8c\x88");
ASSERT_EQ(keys.next(), "\xef\xac\x83");
SUCCEED();
}

TEST(url_search_params, sort_unicode_code_units_edge_case) {
ada::url_search_params search_params("\xf0\x9f\x8c\x88\xef\xac\x83&\xf0\x9f\x8c\x88");
search_params.sort();
ASSERT_EQ(search_params.size(), 2);
auto keys = search_params.get_keys();
ASSERT_EQ(keys.next(), "\xf0\x9f\x8c\x88");
ASSERT_EQ(keys.next(), "\xf0\x9f\x8c\x88\xef\xac\x83");
SUCCEED();
}

0 comments on commit 248b07d

Please sign in to comment.