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