Append an HTTP rel-path to a local filesystem path. The returned path is normalized for the platform.
| 78 | // Append an HTTP rel-path to a local filesystem path. |
| 79 | // The returned path is normalized for the platform. |
| 80 | std::string |
| 81 | path_cat( |
| 82 | beast::string_view base, |
| 83 | beast::string_view path) |
| 84 | { |
| 85 | if(base.empty()) |
| 86 | return std::string(path); |
| 87 | std::string result(base); |
| 88 | #ifdef BOOST_MSVC |
| 89 | char constexpr path_separator = '\\'; |
| 90 | if(result.back() == path_separator) |
| 91 | result.resize(result.size() - 1); |
| 92 | result.append(path.data(), path.size()); |
| 93 | for(auto& c : result) |
| 94 | if(c == '/') |
| 95 | c = path_separator; |
| 96 | #else |
| 97 | char constexpr path_separator = '/'; |
| 98 | if(result.back() == path_separator) |
| 99 | result.resize(result.size() - 1); |
| 100 | result.append(path.data(), path.size()); |
| 101 | #endif |
| 102 | return result; |
| 103 | } |
| 104 | |
| 105 | // Return a response for the given request. |
| 106 | // |
no test coverage detected