Example #1
0
File: Uri.cs Project: xored/f4
        //////////////////////////////////////////////////////////////////////////
        // Plus
        //////////////////////////////////////////////////////////////////////////
        public Uri plus(Uri r)
        {
            // if r is more or equal as absolute as base, return r
              if (r.m_scheme != null) return r;
              if (r.m_host != null && this.m_scheme == null) return r;
              if (r.isPathAbs() && this.m_host == null) return r;

              // this algorthm is lifted straight from
              // RFC 3986 (5.2.2) Transform References;
              Uri baseUri = this;
              Sections t = new Sections();
              if (r.m_host != null)
              {
            t.setAuth(r);
            t.setPath(r);
            t.setQuery(r);
              }
              else
              {
            if (r.m_pathStr == null || r.m_pathStr == "")
            {
              t.setPath(baseUri);
              if (r.m_queryStr != null)
            t.setQuery(r);
              else
            t.setQuery(baseUri);
            }
            else
            {
              if (r.m_pathStr.StartsWith("/"))
            t.setPath(r);
              else
            merge(t, baseUri, r);
              t.setQuery(r);
            }
            t.setAuth(baseUri);
              }
              t.scheme = baseUri.m_scheme;
              t.frag   = r.m_frag;
              t.normalize();
              return new Uri(t);
        }