예제 #1
0
파일: XUri-Test.cs 프로젝트: heran/DReAM
        public void Similarity_works_with_http_and_https()
        {
            var httpsUri    = new XUri("https://foo/a/b/c");
            var httpUri     = new XUri("http://foo/a/b/c");
            var uri         = new XUri("https://foo/a/b/c/d");
            var resultHttps = uri.Similarity(httpsUri);
            var resultHttp  = uri.Similarity(httpUri);

            Assert.AreEqual(resultHttp, resultHttps);
        }
예제 #2
0
파일: XUri-Test.cs 프로젝트: heran/DReAM
        public void Similarity_does_not_work_with_http_and_https_using_strict()
        {
            var httpsUri    = new XUri("https://foo/a/b/c");
            var httpUri     = new XUri("http://foo/a/b/c");
            var uri         = new XUri("https://foo/a/b/c/d");
            var resultHttps = uri.Similarity(httpsUri, true);
            var resultHttp  = uri.Similarity(httpUri, true);

            Assert.AreNotEqual(resultHttp, resultHttps);
        }
예제 #3
0
        /// <summary>
        /// Convert a Uri to a host local Uri, if possible.
        /// </summary>
        /// <remarks>
        /// Will return the original Uri if there is no local equivalent.
        /// </remarks>
        /// <param name="uri">Uri to convert.</param>
        /// <returns>Local Uri.</returns>
        public XUri AsLocalUri(XUri uri)
        {
            XUri result = uri;

            if (uri.Similarity(PublicUri) == PublicUri.MaxSimilarity)
            {
                result = uri.ChangePrefix(PublicUri, Env.LocalMachineUri);
            }
            else if ((ServerUri != null) && (uri.Similarity(ServerUri) == ServerUri.MaxSimilarity))
            {
                result = uri.ChangePrefix(ServerUri, Env.LocalMachineUri);
            }
            return(result);
        }
예제 #4
0
        //--- Interface Methods ---
        int IPlugEndpoint.GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
        {
            normalized = uri;
            int similarity = uri.Similarity(_uri);

            return((similarity >= _minSimilarity) ? similarity : 0);
        }
예제 #5
0
        /// <summary>
        /// Convert a Uri to uri relative to the server's public uri, if possible.
        /// </summary>
        /// <remarks>
        /// Will return the original Uri if there is no public equivalent.
        /// </remarks>
        /// <param name="uri">Uri to convert.</param>
        /// <returns>Public Uri.</returns>
        public XUri AsServerUri(XUri uri)
        {
            XUri result = uri;

            if ((ServerUri != null) && (uri.Similarity(Env.LocalMachineUri) == Env.LocalMachineUri.MaxSimilarity))
            {
                result = uri.ChangePrefix(Env.LocalMachineUri, ServerUri);
            }
            return(result);
        }
예제 #6
0
        /// <summary>
        /// Convert a Uri to uri relative to the requests public uri, if possible.
        /// </summary>
        /// <remarks>
        /// Will return the original Uri if there is no public equivalent.
        /// </remarks>
        /// <param name="uri">Uri to convert.</param>
        /// <returns>Public Uri.</returns>
        public XUri AsPublicUri(XUri uri)
        {
            XUri result = uri;

            if (uri.Similarity(Env.LocalMachineUri) == Env.LocalMachineUri.MaxSimilarity)
            {
                result = uri.ChangePrefix(Env.LocalMachineUri, PublicUri);
            }
            return(result);
        }
예제 #7
0
 //--- Interface Methods ---
 int IPlugEndpoint.GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
 {
     normalized = uri;
     int similarity = uri.Similarity(_uri);
     return (similarity >= _minSimilarity) ? similarity : 0;
 }
예제 #8
0
 public void Similarity_works_with_http_and_https()
 {
     var httpsUri = new XUri("https://foo/a/b/c");
     var httpUri = new XUri("http://foo/a/b/c");
     var uri = new XUri("https://foo/a/b/c/d");
     var resultHttps = uri.Similarity(httpsUri);
     var resultHttp = uri.Similarity(httpUri);
     Assert.AreEqual(resultHttp, resultHttps);
 }
예제 #9
0
 public void Similarity_does_not_work_with_http_and_https_using_strict()
 {
     var httpsUri = new XUri("https://foo/a/b/c");
     var httpUri = new XUri("http://foo/a/b/c");
     var uri = new XUri("https://foo/a/b/c/d");
     var resultHttps = uri.Similarity(httpsUri, true);
     var resultHttp = uri.Similarity(httpUri, true);
     Assert.AreNotEqual(resultHttp, resultHttps);
 }