XRBSourceXRBURI

class URI

This class is superceeded by XRB::Reference.

Definitions

attr :path

The path component of the URI, e.g. /foo/bar/index.html

attr :query_string

The un-parsed query string of the URI, e.g. 'x=10&y=20'

attr :fragment

A fragment identifier, the part after the '#'

attr :parameters

User supplied parameters that will be appended to the query part.

NON_PCHAR = /([^a-zA-Z0-9_\-\.~!$&'()*+,;=:@\/]+)/.freeze

According to https://tools.ietf.org/html/rfc3986#section-3.3, we escape non-pchar.

def escape(string)

Escapes a generic string, using percent encoding.

Implementation

def escape(string)
	encoding = string.encoding
	string.b.gsub(/([^a-zA-Z0-9_.\-]+)/) do |m|
		"%" + m.unpack("H2" * m.bytesize).join("%").upcase
	end.force_encoding(encoding)
end