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