Exemplo n.º 1
0
 void Reset(Url baseUrl)
 {
     _schemeData = String.Empty;
     _scheme     = baseUrl._scheme;
     _host       = baseUrl._host;
     _path       = baseUrl._path;
     _port       = baseUrl._port;
     _relative   = KnownProtocols.IsRelative(_scheme);
 }
Exemplo n.º 2
0
 private Url(String scheme, String host, String port)
 {
     _schemeData = String.Empty;
     _path       = String.Empty;
     _scheme     = scheme;
     _host       = host;
     _port       = port;
     _relative   = KnownProtocols.IsRelative(_scheme);
 }
Exemplo n.º 3
0
        Boolean ParseScheme(String input, Boolean onlyScheme = false)
        {
            if (input.Length > 0 && input[0].IsLetter())
            {
                var index = 1;

                while (index < input.Length)
                {
                    var c = input[index];

                    if (c.IsAlphanumericAscii() || c == Specification.Plus || c == Specification.Minus || c == Specification.Dot)
                    {
                        index++;
                    }
                    else if (c == Specification.Colon)
                    {
                        var originalScheme = _scheme;
                        _scheme = input.Substring(0, index).ToLowerInvariant();

                        if (onlyScheme)
                        {
                            return(true);
                        }

                        _relative = KnownProtocols.IsRelative(_scheme);

                        if (_scheme == KnownProtocols.File)
                        {
                            return(RelativeState(input, index + 1));
                        }
                        else if (!_relative)
                        {
                            return(ParseSchemeData(input, index + 1));
                        }
                        else if (originalScheme == _scheme)
                        {
                            c = input[++index];

                            if (c == Specification.Solidus && index + 2 < input.Length && input[index + 1] == Specification.Solidus)
                            {
                                return(IgnoreSlashesState(input, index + 2));
                            }

                            return(RelativeState(input, index));
                        }

                        if (input[++index] == Specification.Solidus && ++index < input.Length && input[index] == Specification.Solidus)
                        {
                            return(IgnoreSlashesState(input, index + 1));
                        }

                        return(IgnoreSlashesState(input, index));
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (onlyScheme)
            {
                return(false);
            }

            return(RelativeState(input, 0));
        }