LCOV - code coverage report
Current view: top level - libs/http/src/server/detail - route_match.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 94.4 % 36 34
Test Date: 2026-02-02 17:02:49 Functions: 100.0 % 3 3

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com)
       3              : //
       4              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6              : //
       7              : // Official repository: https://github.com/cppalliance/http
       8              : //
       9              : 
      10              : #include "src/server/detail/pct_decode.hpp"
      11              : #include "src/server/detail/route_match.hpp"
      12              : 
      13              : namespace boost {
      14              : namespace http {
      15              : namespace detail {
      16              : 
      17          179 : router_base::
      18              : matcher::
      19              : matcher(
      20              :     std::string_view pat,
      21          179 :     bool end_arg)
      22          179 :     : decoded_pat_(
      23            0 :         [&pat]
      24              :         {
      25          179 :             auto s = pct_decode(pat);
      26          179 :             if( s.size() > 1
      27          179 :                 && s.back() == '/')
      28            0 :                 s.pop_back();
      29          179 :             return s;
      30          358 :         }())
      31          179 :     , end_(end_arg)
      32          358 :     , slash_(pat == "/")
      33              : {
      34          179 :     if(! slash_)
      35              :     {
      36          136 :         auto rv = parse_route_pattern(decoded_pat_);
      37          136 :         if(rv.has_error())
      38           12 :             ec_ = rv.error();
      39              :         else
      40          124 :             pattern_ = std::move(rv.value());
      41          136 :     }
      42          179 : }
      43              : 
      44              : bool
      45          142 : router_base::
      46              : matcher::
      47              : operator()(
      48              :     route_params_base& p,
      49              :     match_result& mr) const
      50              : {
      51          142 :     BOOST_ASSERT(! p.path.empty());
      52              : 
      53              :     // Root pattern special case
      54          142 :     if(slash_ && (!end_ || p.path == "/"))
      55              :     {
      56           40 :         mr.adjust_path(p, 0);
      57           40 :         return true;
      58              :     }
      59              : 
      60              :     // Convert bitflags to match_options
      61              :     match_options opts{
      62          102 :         p.case_sensitive,
      63          102 :         p.strict,
      64          102 :         end_
      65          102 :     };
      66              : 
      67          102 :     auto rv = match_route(p.path, pattern_, opts);
      68          102 :     if(rv.has_error())
      69           15 :         return false;
      70              : 
      71           87 :     auto const n = rv->matched_length;
      72           87 :     mr.adjust_path(p, n);
      73           87 :     mr.params_ = std::move(rv->params);
      74           87 :     return true;
      75          102 : }
      76              : 
      77              : } // detail
      78              : } // http
      79              : } // boost
        

Generated by: LCOV version 2.3