Sha256: 688a355ce4c362d0f662bef49fbd0d69db25045230f3dabb5adaec65c41fc3c2

Contents?: true

Size: 439 Bytes

Versions: 5

Compression:

Stored size: 439 Bytes

Contents

module RestCore; end
module RestCore::ParseLink
  module_function
  # http://tools.ietf.org/html/rfc5988
  parname = '"?([^"]+)"?'
  LINKPARAM = /#{parname}=#{parname}/u
  def parse_link link
    link.split(',').inject({}) do |r, value|
      uri, *pairs = value.split(';')
      params = Hash[pairs.map{ |p| p.strip.match(LINKPARAM)[1..2] }]
      r[params['rel']] = params.merge('uri' => uri[/<([^>]+)>/u, 1])
      r
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rest-core-3.4.1 lib/rest-core/util/parse_link.rb
rest-core-3.4.0 lib/rest-core/util/parse_link.rb
rest-core-3.3.3 lib/rest-core/util/parse_link.rb
rest-core-3.3.2 lib/rest-core/util/parse_link.rb
rest-core-3.3.1 lib/rest-core/util/parse_link.rb