Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        //--- Interface Methods ---
        int IPlugEndpoint.GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
        {
            normalized = uri;
            int similarity = uri.Similarity(_uri);

            return((similarity >= _minSimilarity) ? similarity : 0);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 7
0
 //--- Interface Methods ---
 int IPlugEndpoint.GetScoreWithNormalizedUri(XUri uri, out XUri normalized)
 {
     normalized = uri;
     int similarity = uri.Similarity(_uri);
     return (similarity >= _minSimilarity) ? similarity : 0;
 }
Esempio n. 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);
 }
Esempio n. 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);
 }