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