gapic-generator/lib/gapic/path_pattern/pattern.rb
##
# Converts the PathPattern into a regex string
# @return [String]
Converts the PathPattern into a regex string
Converts the PathPattern into a regex string
def to_regex_str
        regex_str = segments.first.to_regex_str
        segments.drop(1).each_with_index do |segment, _index|
          is_double_wildcard = segment.pattern == "**"
          regex_str = if is_double_wildcard
                        "#{regex_str}(?:/.*)?"
                      else
                        "#{regex_str}/#{segment.to_regex_str}"
                      end
        end
        regex_str
      end
def to_regex_str regex_str = segments . first . to_regex_str segments . drop ( 1 ) . each_with_index do | segment , _index | is_double_wildcard = segment . pattern == "**" regex_str = if is_double_wildcard "#{regex_str}(?:/.*)?" else "#{regex_str}/#{segment.to_regex_str}" end end regex_str end
Converts the PathPattern into a regex string
Converts the PathPattern into a regex string
# for double wildcards the leading `/`` is optional # e.g. `foo/**` should match `foo` # this is why segments 'bring' the leading separator # with them as they build the pattern
None
String