diff --git a/include/tools/stringTools.h b/include/tools/stringTools.h index 7dd2605ed..f106d7893 100644 --- a/include/tools/stringTools.h +++ b/include/tools/stringTools.h @@ -70,5 +70,7 @@ T extractFromString(const std::string& str) { iss >> ret; return ret; } + +bool startsWith(const std::string& base, const std::string& start); } //namespace kiwix #endif diff --git a/src/tools/stringTools.cpp b/src/tools/stringTools.cpp index feb0f34f0..c1025b522 100644 --- a/src/tools/stringTools.cpp +++ b/src/tools/stringTools.cpp @@ -377,3 +377,11 @@ std::string kiwix::normalize(const std::string& word) { return kiwix::lcAll(word); } + + +bool kiwix::startsWith(const std::string& base, const std::string& start) +{ + return start.length() <= base.length() + && std::equal(start.begin(), start.end(), base.begin()); +} +