public void GetPermanentUrlWithParentPermanentUrlAndRemoveInnermostReturnUrl() { string parameterName = "Param"; string parameterValue = "123456789 123456789 123456789 123456789 "; NameValueCollection queryString = new NameValueCollection(); queryString.Add(parameterName, parameterValue); NameValueCollection expectedQueryString = new NameValueCollection(); expectedQueryString.Add(queryString); string parentUrl = _currentHttpContext.Request.Url.AbsolutePath; parentUrl += UrlUtility.FormatQueryString(_currentHttpContext.Request.QueryString); parentUrl = UrlUtility.DeleteParameter(parentUrl, WxeHandler.Parameters.ReturnUrl); expectedQueryString.Add(WxeHandler.Parameters.ReturnUrl, parentUrl); string expectedUrl = UrlUtility.GetAbsoluteUrl(new HttpContextWrapper(_currentHttpContext), _resource); expectedUrl += UrlUtility.FormatQueryString(expectedQueryString); string permanentUrl = _currentWxeContext.GetPermanentUrl(_functionType, queryString, true); Assert.That(permanentUrl, Is.Not.Null); Assert.That(permanentUrl, Is.EqualTo(expectedUrl)); }
public void DeleteParameterFromUrlWithEmptyFirstParameter() { string url = "http://localhost/Default.html"; string parameter1 = "Parameter1"; string parameter2 = "Parameter2"; string value1 = "Value1ä#"; string value2 = "Value2"; string original = string.Format( "{0}?{1}={2}&{3}={4}", url, parameter1, string.Empty, parameter2, HttpUtility.UrlEncode(value2, _currentEncoding)); string expected = string.Format( "{0}?{3}={4}", url, parameter1, HttpUtility.UrlEncode(value1, _currentEncoding), parameter2, HttpUtility.UrlEncode(value2, _currentEncoding)); string actual = UrlUtility.DeleteParameter(original, parameter1); Assert.That(actual, Is.EqualTo(expected)); }
public void DeleteParameterFromUrlWithQuestionMark() { string url = "http://localhost/Default.html?"; string parameter1 = "Parameter1"; string expected = url; string actual = UrlUtility.DeleteParameter(url, parameter1); Assert.That(actual, Is.EqualTo(expected)); }
public void DeleteParameterFromUrlWithNoUrl() { string parameter1 = "Parameter1"; string value1 = "Value1ä#"; string original = string.Format( "?{0}={1}", parameter1, HttpUtility.UrlEncode(value1, _currentEncoding)); string expected = string.Empty; string actual = UrlUtility.DeleteParameter(original, parameter1); Assert.That(actual, Is.EqualTo(expected)); }
private StringCollection ExtractReturnUrls(string url) { StringCollection returnUrls = new StringCollection(); while (!string.IsNullOrEmpty(url)) { string currentUrl = url; url = UrlUtility.GetParameter(currentUrl, WxeHandler.Parameters.ReturnUrl, _httpContext.Request.ContentEncoding); if (!string.IsNullOrEmpty(url)) { currentUrl = UrlUtility.DeleteParameter(currentUrl, WxeHandler.Parameters.ReturnUrl); } returnUrls.Add(currentUrl); } return(returnUrls); }