Skip to content

Commit

Permalink
Fix to handle empty NCP URL path
Browse files Browse the repository at this point in the history
  • Loading branch information
lo-simon committed Oct 6, 2023
1 parent c1a9aca commit 84f13d4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Development/nmos/control_protocol_ws_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ namespace nmos
const auto& ws_ncp_path = connection_uri.path();
slog::log<slog::severities::too_much_info>(gate, SLOG_FLF) << "Received websocket message: " << msg << " on connection: " << ws_ncp_path;

// extract the control protocol api version from the ws_ncp_path
const auto version = nmos::parse_api_version(web::uri::split_path(ws_ncp_path).back());

auto websocket = websockets.right.find(connection_id);
if (websockets.right.end() != websocket)
{
Expand All @@ -241,6 +238,11 @@ namespace nmos
{
try
{
// extract the control protocol api version from the ws_ncp_path
if (web::uri::split_path(ws_ncp_path).empty()) { throw std::invalid_argument("empty URL"); }
const auto version = nmos::parse_api_version(web::uri::split_path(ws_ncp_path).back());

// convert message to JSON
const auto message = value::parse(utility::conversions::to_string_t(msg));

// validate the base-message
Expand Down

0 comments on commit 84f13d4

Please sign in to comment.