1- // Copyright (C) 2007-2020 Xtensive LLC.
1+ // Copyright (C) 2007-2021 Xtensive LLC.
22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44// Created by: Alex Yakunin
@@ -77,7 +77,7 @@ public class UrlInfo :
7777 ISerializable
7878 {
7979 private static readonly Regex Pattern = new Regex (
80- @"^(?'proto'[^:]*)://" +
80+ @"^(?'proto'[^:]*[^sS])(?'secure'[sS]? )://" +
8181 @"((?'username'[^:@]*)" +
8282 @"(:(?'password'[^@]*))?@)?" +
8383 @"(?'host'[^:/]*)" +
@@ -88,6 +88,7 @@ public class UrlInfo :
8888
8989 private string url = string . Empty ;
9090 private string protocol = string . Empty ;
91+ private bool secure = false ;
9192 private string host = string . Empty ;
9293 private int port ;
9394 private string resource = string . Empty ;
@@ -116,6 +117,16 @@ public string Protocol
116117 get { return protocol ; }
117118 }
118119
120+ /// <summary>
121+ /// Gets the security part of the current <see cref="Url"/>
122+ /// Scheme with 's' suffix is secure.
123+ /// </summary>
124+ public bool Secure
125+ {
126+ [ DebuggerStepThrough ]
127+ get => secure ;
128+ }
129+
119130 /// <summary>
120131 /// Gets the host part of the current <see cref="Url"/>
121132 /// (e.g. <b>"localhost"</b> is the host part of the "tcp://admin:password@<b>localhost</b>/resource" URL).
@@ -237,6 +248,7 @@ private static void Parse(string url, UrlInfo info)
237248 info . resource = UrlDecode ( result . Result ( "${resource}" ) ) ;
238249 info . host = UrlDecode ( result . Result ( "${host}" ) ) ;
239250 info . protocol = UrlDecode ( result . Result ( "${proto}" ) ) ;
251+ info . secure = ! string . IsNullOrEmpty ( result . Result ( "${secure}" ) ) ;
240252 info . port = @port ;
241253 info . parameters = new ReadOnlyDictionary < string , string > ( @params ) ;
242254 }
0 commit comments