Skip to content

Commit

Permalink
Fix slashes in topic names
Browse files Browse the repository at this point in the history
  • Loading branch information
EzraBrooks committed Dec 26, 2024
1 parent 965ed73 commit 546aa8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/image_streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#endif

#include <iostream>
#include <regex>

namespace web_video_server
{
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/web_video_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <chrono>
#include <vector>
#include <regex>

#include <boost/algorithm/string/predicate.hpp>
#include <opencv2/opencv.hpp>
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 546aa8b

Please sign in to comment.