Skip to content

Commit

Permalink
fix trim issue in frontend input
Browse files Browse the repository at this point in the history
  • Loading branch information
ChandiH committed Aug 18, 2024
1 parent 70a0d57 commit 7c96027
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/util/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,19 @@ std::vector<std::string> Utils::getHostListFromProperties() {
}

static inline std::string trim_right_copy(const std::string &s, const std::string &delimiters) {
return s.substr(0, s.find_last_not_of(delimiters) + 1);
size_t end = s.find_last_not_of(delimiters);
if (end == std::string::npos) {
return ""; // Return empty string if all characters are delimiters
}
return s.substr(0, end + 1);
}

static inline std::string trim_left_copy(const std::string &s, const std::string &delimiters) {
return s.substr(s.find_first_not_of(delimiters));
size_t start = s.find_first_not_of(delimiters);
if (start == std::string::npos) {
return ""; // Return empty string if all characters are delimiters
}
return s.substr(start);
}

std::string Utils::trim_copy(const std::string &s, const std::string &delimiters) {
Expand Down

0 comments on commit 7c96027

Please sign in to comment.