LCOV - code coverage report
Current view: top level - src/server/detail - route_match.cpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 94.6 % 37 35
Test Date: 2026-02-09 01:37:05 Functions: 100.0 % 3 3

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.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              : 
      16          278 : detail::router_base::
      17              : matcher::
      18              : matcher(
      19              :     std::string_view pat,
      20          278 :     bool end_arg)
      21          278 :     : decoded_pat_(
      22            0 :         [&pat]
      23              :         {
      24          278 :             auto s = detail::pct_decode(pat);
      25          278 :             if( s.size() > 1
      26          278 :                 && s.back() == '/')
      27            0 :                 s.pop_back();
      28          278 :             return s;
      29          556 :         }())
      30          278 :     , end_(end_arg)
      31          556 :     , slash_(pat == "/")
      32              : {
      33          278 :     if(! slash_)
      34              :     {
      35          180 :         auto rv = parse_route_pattern(decoded_pat_);
      36          180 :         if(rv.has_error())
      37           12 :             ec_ = rv.error();
      38              :         else
      39          168 :             pattern_ = std::move(rv.value());
      40          180 :     }
      41          278 : }
      42              : 
      43              : bool
      44          336 : detail::router_base::
      45              : matcher::
      46              : operator()(
      47              :     route_params& p,
      48              :     match_result& mr) const
      49              : {
      50          336 :     BOOST_ASSERT(! p.path.empty());
      51              : 
      52              :     // Root pattern special case
      53          336 :     if(slash_ && (!end_ || p.path == "/"))
      54              :     {
      55          132 :         mr.adjust_path(p, 0);
      56          132 :         return true;
      57              :     }
      58              : 
      59              :     // Convert bitflags to match_options
      60          204 :     auto& pv = *detail::route_params_access{p};
      61              :     detail::match_options opts{
      62          204 :         pv.case_sensitive,
      63          204 :         pv.strict,
      64          204 :         end_
      65          204 :     };
      66              : 
      67          204 :     auto rv = match_route(p.path, pattern_, opts);
      68          204 :     if(rv.has_error())
      69           39 :         return false;
      70              : 
      71          165 :     auto const n = rv->matched_length;
      72          165 :     mr.adjust_path(p, n);
      73          165 :     mr.params_ = std::move(rv->params);
      74          165 :     return true;
      75          204 : }
      76              : 
      77              : } // http
      78              : } // boost
        

Generated by: LCOV version 2.3