Reference resolution

See: http://tools.ietf.org/html/rfc3986#section-5.2