Skip to content

Commit ad2f131

Browse files
Update server-mmojo.cpp
Signed-off-by: Brad Hutchings <[email protected]>
1 parent eca1398 commit ad2f131

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/server/server-mmojo.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
#ifdef COSMOCC
3636
#include <cosmo.h>
3737
#endif
38+
39+
bool ends_with (std::string const &fullString, std::string const &ending);
40+
bool ends_with (std::string const &fullString, std::string const &ending) {
41+
if (fullString.length() >= ending.length()) {
42+
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
43+
}
44+
else {
45+
return false;
46+
}
47+
}
3848
// mmojo-server END
3949

4050
using json = nlohmann::ordered_json;
@@ -3894,12 +3904,12 @@ int main(int argc, char ** argv) {
38943904

38953905
return false;
38963906
};
3897-
3907+
38983908
auto middleware_server_state = [&res_error, &state](const httplib::Request & req, httplib::Response & res) {
38993909
server_state current_state = state.load();
39003910
if (current_state == SERVER_STATE_LOADING_MODEL) {
39013911
auto tmp = string_split<std::string>(req.path, '.');
3902-
if (req.path == "/" || tmp.back() == "html" || req.path.str.ends_with("/") || req.path.str.ends_with(".html")) {
3912+
if (req.path == "/" || tmp.back() == "html" || ends_with(req.path, "/") || ends_with(req.path, ".html")) {
39033913
// mmojo-server START
39043914
// res.set_content(reinterpret_cast<const char*>(loading_html), loading_html_len, "text/html; charset=utf-8");
39053915
res.set_content(reinterpret_cast<const char*>(loading_mmojo_html), loading_mmojo_html_len, "text/html; charset=utf-8");

0 commit comments

Comments
 (0)