Skip to content

Commit 546aa8b

Browse files
committed
Fix slashes in topic names
1 parent 965ed73 commit 546aa8b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/image_streamer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#endif
3838

3939
#include <iostream>
40+
#include <regex>
4041

4142
namespace web_video_server
4243
{
@@ -46,7 +47,7 @@ ImageStreamer::ImageStreamer(
4647
async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node)
4748
: request_(request), connection_(connection), node_(node), inactive_(false)
4849
{
49-
topic_ = request.get_query_param_value_or_default("topic", "");
50+
topic_ = std::regex_replace(request.get_query_param_value_or_default("topic", ""), std::regex(R"(%2F)"), "/");
5051
}
5152

5253
ImageStreamer::~ImageStreamer()

src/web_video_server.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include <chrono>
3434
#include <vector>
35+
#include <regex>
3536

3637
#include <boost/algorithm/string/predicate.hpp>
3738
#include <opencv2/opencv.hpp>
@@ -172,7 +173,7 @@ bool WebVideoServer::handle_stream(
172173
{
173174
std::string type = request.get_query_param_value_or_default("type", default_stream_type_);
174175
if (stream_types_.find(type) != stream_types_.end()) {
175-
std::string topic = request.get_query_param_value_or_default("topic", "");
176+
std::string topic = std::regex_replace(request.get_query_param_value_or_default("topic", ""), std::regex(R"(%2F)"), "/");
176177
// Fallback for topics without corresponding compressed topics
177178
if (type == std::string("ros_compressed")) {
178179
std::string compressed_topic_name = topic + "/compressed";

0 commit comments

Comments
 (0)