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

src: use ostringstream instead of string in FromFilePath() #50253

Closed
wants to merge 1 commit into from
Closed
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
src: use ostringstream instead of string in FromFilePath()
pluris committed Oct 18, 2023

Verified

This commit was signed with the committer’s verified signature.
addaleax Anna Henningsen
commit b41cc99d010d04a885e8ebd9385f7aab3f3d64cc
8 changes: 4 additions & 4 deletions src/node_url.cc
Original file line number Diff line number Diff line change
@@ -418,12 +418,12 @@ void BindingData::RegisterExternalReferences(
}

std::string FromFilePath(const std::string_view file_path) {
std::string escaped_file_path;
std::ostringstream escaped_file_path;
for (size_t i = 0; i < file_path.length(); ++i) {
escaped_file_path += file_path[i];
if (file_path[i] == '%') escaped_file_path += "25";
escaped_file_path << file_path[i];
if (file_path[i] == '%') escaped_file_path << "25";
}
return ada::href_from_file(escaped_file_path);
return ada::href_from_file(escaped_file_path.str());
}

} // namespace url