Sha256: c3f2a176857c57030b5db369f93e1fa17f292b3931a4b2f3efc3918c97323176

Contents?: true

Size: 570 Bytes

Versions: 2

Compression:

Stored size: 570 Bytes

Contents

module Pacto
  class UriPattern
    class << self
      def for(request)
        if Pacto.configuration.strict_matchers
          build_strict_uri_pattern(request)
        else
          build_relaxed_uri_pattern(request)
        end
      end

      def build_strict_uri_pattern(request)
        "#{request.host}#{request.path}"
      end

      def build_relaxed_uri_pattern(request)
        path_pattern = request.path.gsub(/\/:\w+/, '/[^\/\?#]+')
        host_pattern = Regexp.quote(request.host)
        /#{host_pattern}#{path_pattern}/
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pacto-0.3.1 lib/pacto/stubs/uri_pattern.rb
pacto-0.3.0 lib/pacto/stubs/uri_pattern.rb