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

improves slightly the style of url_search_params, makes to_string() c… #614

Merged
merged 1 commit into from
Mar 20, 2024
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
8 changes: 4 additions & 4 deletions include/ada/url_search_params-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ inline void url_search_params::initialize(std::string_view input) {
auto equal = current.find('=');

if (equal == std::string_view::npos) {
auto name = std::string(current);
std::string name(current);
std::replace(name.begin(), name.end(), '+', ' ');
params.emplace_back(unicode::percent_decode(name, name.find('%')), "");
} else {
auto name = std::string(current.substr(0, equal));
auto value = std::string(current.substr(equal + 1));
std::string name(current.substr(0, equal));
std::string value(current.substr(equal + 1));

std::replace(name.begin(), name.end(), '+', ' ');
std::replace(value.begin(), value.end(), '+', ' ');
Expand Down Expand Up @@ -109,7 +109,7 @@ inline bool url_search_params::has(std::string_view key,
return entry != params.end();
}

inline std::string url_search_params::to_string() {
inline std::string url_search_params::to_string() const {
auto character_set = ada::character_sets::WWW_FORM_URLENCODED_PERCENT_ENCODE;
std::string out{};
for (size_t i = 0; i < params.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion include/ada/url_search_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct url_search_params {
/**
* @see https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
*/
inline std::string to_string();
inline std::string to_string() const;

/**
* Returns a simple JS-style iterator over all of the keys in this
Expand Down
Loading