Exemplo n.º 1
0
		public void NormalAbsoluteUriHostAndSchemeTest()
		{
			Uri uri1 = new Uri("http://www.baidu.com/test", UriKind.RelativeOrAbsolute);
			Uri uri2 = new Uri("http://www.BAIDU.com/test", UriKind.RelativeOrAbsolute);

			Assert.IsTrue(uri1.CompareSchemeAndHost(uri2));
		}
Exemplo n.º 2
0
		public void DefaultPortNotEqualAbsoluteTest()
		{
			Uri uri1 = new Uri("http://www.baidu.com/test", UriKind.RelativeOrAbsolute);
			Uri uri2 = new Uri("http://www.baidu.com:81/test", UriKind.RelativeOrAbsolute);

			Assert.IsFalse(uri1.CompareSchemeAndHost(uri2));
		}
Exemplo n.º 3
0
		/// <summary>
		/// 目标Url是否合法
		/// </summary>
		/// <param name="destUrl"></param>
		/// <param name="urlCheckParts">需要检查的url中的部分</param>
		/// <returns></returns>
		public bool UrlIsValid(Uri destUrl, AccessTicketUrlCheckParts urlCheckParts)
		{
			bool result = true;

			if (this.DestinationUrl.IsNotEmpty())
			{
				Uri uri1 = new Uri(this.DestinationUrl, UriKind.RelativeOrAbsolute);

				if ((urlCheckParts & AccessTicketUrlCheckParts.SchemeHostAndPort) != AccessTicketUrlCheckParts.None)
					result = uri1.CompareSchemeAndHost(destUrl);

				if (result && (urlCheckParts & AccessTicketUrlCheckParts.PathAndParameters) != AccessTicketUrlCheckParts.None)
					result = uri1.ComparePathAndParameters(destUrl, AccessTicket.AccessTicketParamName);
			}

			return result;
		}
Exemplo n.º 4
0
		public void OneUriIsNullNotEqualTest()
		{
			Uri uri1 = new Uri("http://www.baidu.com/test", UriKind.RelativeOrAbsolute);
			Uri uri2 = null;

			Assert.IsFalse(uri1.CompareSchemeAndHost(uri2));
		}
Exemplo n.º 5
0
		public void AllRelativeEqualHostAndSchemeTest()
		{
			Uri uri1 = new Uri("/test", UriKind.RelativeOrAbsolute);
			Uri uri2 = new Uri("/test1", UriKind.RelativeOrAbsolute);

			Assert.IsTrue(uri1.CompareSchemeAndHost(uri2));
		}