288742 : MatcherBase(pattern) {
288743 constexpr const char marker[] = "/:";
288744
288745
288746 std::size_t last_param_end = 0;
288747
288748#ifndef CPPHTTPLIB_NO_EXCEPTIONS
288749
288750
288751
288752
288753 std::unordered_set<std::string> param_name_set;
288754#endif
288755
288756 while (true) {
288757 const auto marker_pos = pattern.find(
288758 marker, last_param_end == 0 ? last_param_end : last_param_end - 1);
288759 if (marker_pos == std::string::npos) { break; }
288760
288761 static_fragments_.push_back(
288762 pattern.substr(last_param_end, marker_pos - last_param_end + 1));
288763
288764 const auto param_name_start = marker_pos + str_len(marker);
288765
288766 auto sep_pos = pattern.find(separator, param_name_start);
288767 if (sep_pos == std::string::npos) { sep_pos = pattern.length(); }
288768
288769 auto param_name =
288770 pattern.substr(param_name_start, sep_pos - param_name_start);
288771
288772#ifndef CPPHTTPLIB_NO_EXCEPTIONS
288773 if (param_name_set.find(param_name) != param_name_set.cend()) {
288774 std::string msg = "Encountered path parameter '" + param_name +
288775 "' multiple times in route pattern '" + pattern + "'.";
288776 throw std::invalid_argument(msg);
288777 }
288778#endif
288779
288780 param_names_.push_back(std::move(param_name));
288781
288782 last_param_end = sep_pos + 1;
288783 }
288784
288785 if (last_param_end < pattern.length()) {
288786 static_fragments_.push_back(pattern.substr(last_param_end));
288787 }
288788}