def component_matches(component, uri)
      component_template = component_templates[component]
      return {} unless component_template

      component_url = uri.public_send(component).to_s
      mappings = component_template.extract(component_url)
      return mappings if mappings

      # to support Addressable's expansion of queries
      # ensure it's parsing the fragment as appropriate (e.g. {?params*})
      prefix = component_prefixes[component]
      return nil unless prefix

      component_template.extract(prefix + component_url)
    end
def component_matches(component, uri)
      component_template = component_templates[component]
      return {} unless component_template

      component_url = uri.public_send(component).to_s
      mappings = component_template.extract(component_url)
      return mappings if mappings

      # to support Addressable's expansion of queries
      # ensure it's parsing the fragment as appropriate (e.g. {?params*})
      prefix = component_prefixes[component]
      return nil unless prefix

      component_template.extract(prefix + component_url)
    end
Returns empty hash if the template omits the component or a set of
 substitutions if the provided URI component matches the template
 component or nil if the match fails.