From 546aa8b11db3cd84d9422ecdd6b464b449674d3a Mon Sep 17 00:00:00 2001 From: Ezra Brooks Date: Thu, 26 Dec 2024 14:27:13 -0700 Subject: [PATCH] Fix slashes in topic names --- src/image_streamer.cpp | 3 ++- src/web_video_server.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/image_streamer.cpp b/src/image_streamer.cpp index 8a83958..83e8c9c 100644 --- a/src/image_streamer.cpp +++ b/src/image_streamer.cpp @@ -37,6 +37,7 @@ #endif #include +#include namespace web_video_server { @@ -46,7 +47,7 @@ ImageStreamer::ImageStreamer( async_web_server_cpp::HttpConnectionPtr connection, rclcpp::Node::SharedPtr node) : request_(request), connection_(connection), node_(node), inactive_(false) { - topic_ = request.get_query_param_value_or_default("topic", ""); + topic_ = std::regex_replace(request.get_query_param_value_or_default("topic", ""), std::regex(R"(%2F)"), "/"); } ImageStreamer::~ImageStreamer() diff --git a/src/web_video_server.cpp b/src/web_video_server.cpp index 5f548c3..30a6fe9 100644 --- a/src/web_video_server.cpp +++ b/src/web_video_server.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -172,7 +173,7 @@ bool WebVideoServer::handle_stream( { std::string type = request.get_query_param_value_or_default("type", default_stream_type_); if (stream_types_.find(type) != stream_types_.end()) { - std::string topic = request.get_query_param_value_or_default("topic", ""); + std::string topic = std::regex_replace(request.get_query_param_value_or_default("topic", ""), std::regex(R"(%2F)"), "/"); // Fallback for topics without corresponding compressed topics if (type == std::string("ros_compressed")) { std::string compressed_topic_name = topic + "/compressed";