/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="fullUrl"> /// The full Url. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters. /// </returns> public static string GetLink(ForumPages page, bool fullUrl, string format, params object[] args) { return(fullUrl ? YafFactoryProvider.UrlBuilder.BuildUrlFull( "g={0}&{1}".FormatWith(page, format.FormatWith(args))) : YafFactoryProvider.UrlBuilder.BuildUrl("g={0}&{1}".FormatWith(page, format.FormatWith(args)))); }
/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="boardSettings">The board settings.</param> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">The full Url.</param> /// <param name="format">Format of parameters.</param> /// <param name="args">Array of page parameters.</param> /// <returns> /// URL to the given page with parameters. /// </returns> public static string GetLink(BoardSettings boardSettings, ForumPages page, bool fullUrl, string format, params object[] args) { return(fullUrl ? FactoryProvider.UrlBuilder.BuildUrlFull( boardSettings, $"g={page}&{string.Format(format, args)}") : FactoryProvider.UrlBuilder.BuildUrl( boardSettings, $"g={page}&{string.Format(format, args)}")); }
/// <summary> /// The render menu item. /// </summary> /// <param name="stringBuilder"> /// The string builder. /// </param> /// <param name="cssClass"> /// The CSS class. /// </param> /// <param name="page"> /// The page. /// </param> /// <param name="getText"> /// The get text. /// </param> /// <param name="parameter"> /// The URL Parameter /// </param> private void RenderMenuItem( StringBuilder stringBuilder, string cssClass, ForumPages page, string getText, string parameter = null) { stringBuilder.AppendFormat( this.PageContext.ForumPageType == page ? @"<a class=""{3} active"" href=""{0}"" title=""{2}"">{1}</a>" : @"<a class=""{3}"" href=""{0}"" title=""{2}"">{1}</a>", parameter.IsSet() ? YafBuildLink.GetLink(page, parameter) : YafBuildLink.GetLink(page), getText, getText, cssClass); }
/// <summary> /// The render menu item. /// </summary> /// <param name="stringBuilder"> /// The string builder. /// </param> /// <param name="cssClass"> /// The CSS class. /// </param> /// <param name="page"> /// The page. /// </param> /// <param name="getText"> /// The get text. /// </param> /// <param name="icon"> /// The icon. /// </param> /// <param name="parameter"> /// The URL Parameter /// </param> private void RenderMenuItem( StringBuilder stringBuilder, string cssClass, ForumPages page, string getText, string icon, string parameter = null) { stringBuilder.AppendFormat( this.PageContext.ForumPageType == page ? @"<a class=""{3} active"" href=""{0}"" title=""{2}"" data-toggle=""tooltip""><i class=""fas fa-{4} mr-1 text-light""></i>{1}</a>" : @"<a class=""{3}"" href=""{0}"" title=""{2}"" data-toggle=""tooltip""><i class=""fas fa-{4} mr-1 text-secondary""></i>{1}</a>", parameter.IsSet() ? BuildLink.GetLink(page, parameter) : BuildLink.GetLink(page), getText, getText, cssClass, icon); }
/// <summary> /// The render menu item. /// </summary> /// <param name="stringBuilder"> /// The string builder. /// </param> /// <param name="cssClass"> /// The CSS class. /// </param> /// <param name="page"> /// The page. /// </param> /// <param name="getText"> /// The get text. /// </param> /// <param name="icon"> /// The icon. /// </param> /// <param name="parameters"> /// The URL Parameter /// </param> private void RenderMenuItem( StringBuilder stringBuilder, string cssClass, ForumPages page, string getText, string icon, object parameters = null) { stringBuilder.AppendFormat( this.PageBoardContext.CurrentForumPage.PageType == page ? @"<a class=""{3} active"" href=""{0}"" title=""{2}"" data-bs-toggle=""tooltip""><i class=""fas fa-{4} me-1 text-light""></i>{1}</a>" : @"<a class=""{3}"" href=""{0}"" title=""{2}"" data-bs-toggle=""tooltip""><i class=""fas fa-{4} me-1 text-secondary""></i>{1}</a>", parameters != null ? this.Get <LinkBuilder>().GetLink(page, parameters) : this.Get <LinkBuilder>().GetLink(page), getText, getText, cssClass, icon); }
private bool ValidPage(ForumPages Page) { if (LockedForum == 0) { return(true); } if (Page == YAF.Classes.Utils.ForumPages.forum || Page == YAF.Classes.Utils.ForumPages.active || Page == YAF.Classes.Utils.ForumPages.activeusers) { return(false); } if (Page == YAF.Classes.Utils.ForumPages.cp_editprofile || Page == YAF.Classes.Utils.ForumPages.cp_pm || Page == YAF.Classes.Utils.ForumPages.cp_message || Page == YAF.Classes.Utils.ForumPages.cp_profile || Page == YAF.Classes.Utils.ForumPages.cp_signature || Page == YAF.Classes.Utils.ForumPages.cp_subscriptions) { return(false); } if (Page == YAF.Classes.Utils.ForumPages.pmessage) { return(false); } return(true); }
/// <summary> /// Redirects to the given page. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> public void Redirect(ForumPages page) { this.Get <HttpResponseBase>().Redirect(this.Get <LinkBuilder>().GetLink(page).Replace("&", "&")); }
/// <summary> /// Redirects to the given page. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> public static void Redirect(ForumPages page) { HttpContext.Current.Response.Redirect(GetLink(page).Replace("&", "&")); }
/// <summary> /// Redirects to the given page with parameters. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> /// <param name="endResponse">True to end the Response, false otherwise.</param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> public static void Redirect(ForumPages page, bool endResponse, string format, params object[] args) { HttpContext.Current.Response.Redirect(GetLink(page, format, args), endResponse); }
/// <summary> /// The build url. /// </summary> /// <param name="boardSettings">The board settings.</param> /// <param name="url">The url.</param> /// <returns> /// The new Url. /// </returns> public override string BuildUrl(object boardSettings, string url) { var yafBoardSettings = boardSettings.ToType <YafBoardSettings>(); var yafTab = new TabController().GetTab(yafBoardSettings.DNNPageTab); if (url.IsNotSet()) { // return BaseURL var baseUrl = Globals.NavigateURL(); if (baseUrl.EndsWith(yafTab.TabName)) { baseUrl = baseUrl.Replace(yafTab.TabName, string.Empty); } if (baseUrl.EndsWith("{0}.aspx".FormatWith(yafTab.TabName))) { baseUrl = baseUrl.Replace("{0}.aspx".FormatWith(yafTab.TabName), string.Empty); } if (baseUrl.EndsWith("{0}.aspx".FormatWith(yafTab.TabName.ToLower()))) { baseUrl = baseUrl.Replace("{0}.aspx".FormatWith(yafTab.TabName.ToLower()), string.Empty); } return(baseUrl); } if (!Config.EnableURLRewriting) { return(Globals.ResolveUrl("{0}&{1}".FormatWith(Globals.ApplicationURL(yafTab.TabID), url))); } var newUrl = new StringBuilder(); var portalSettings = new PortalSettings(yafTab.PortalID); /*var portalSettings = PortalController.GetCurrentPortalSettings(); * * var yafTab = new TabController().GetTab( * yafBoardSettings.DNNPageTab, * portalSettings.PortalId, * false);*/ var boardNameOrPageName = UrlRewriteHelper.CleanStringForURL(yafBoardSettings.Name); var parser = new SimpleURLParameterParser(url); var pageName = parser["g"]; ForumPages forumPage = ForumPages.forum; var getDescription = false; if (pageName.IsSet()) { try { forumPage = pageName.ToEnum <ForumPages>(); getDescription = true; } catch (Exception) { getDescription = false; } } if (getDescription) { switch (forumPage) { case ForumPages.topics: { boardNameOrPageName = UrlRewriteHelper.GetForumName(parser["f"].ToType <int>()); } break; case ForumPages.posts: { if (parser["t"].IsSet()) { var topicName = UrlRewriteHelper.GetTopicName(parser["t"].ToType <int>()); if (topicName.EndsWith("-")) { topicName = topicName.Remove(topicName.Length - 1, 1); } boardNameOrPageName = topicName; } else if (parser["m"].IsSet()) { string topicName; try { topicName = UrlRewriteHelper.GetTopicNameFromMessage(parser["m"].ToType <int>()); if (topicName.EndsWith("-")) { topicName = topicName.Remove(topicName.Length - 1, 1); } } catch (Exception) { topicName = parser["g"]; } boardNameOrPageName = topicName; } } break; case ForumPages.profile: { boardNameOrPageName = UrlRewriteHelper.CleanStringForURL( parser["name"].IsSet() ? parser["name"] : UrlRewriteHelper.GetProfileName(parser["u"].ToType <int>())); } break; case ForumPages.forum: { if (parser["c"].IsSet()) { boardNameOrPageName = UrlRewriteHelper.GetCategoryName(parser["c"].ToType <int>()); } } break; } } newUrl.Append( FriendlyUrlProvider.Instance() .FriendlyUrl( yafTab, "{0}&{1}".FormatWith(Globals.ApplicationURL(yafTab.TabID), url), boardNameOrPageName, portalSettings.DefaultPortalAlias)); // add anchor /*if (parser.HasAnchor) * { * newUrl.AppendFormat("#{0}", parser.Anchor); * }*/ return(newUrl.Length >= 260 ? this.GetStandardUrl(yafTab, url, boardNameOrPageName, portalSettings) : newUrl.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="ForumLink"/> class. /// </summary> /// <param name="forumPage"> /// The forum page. /// </param> public ForumLink(ForumPages forumPage) { this.ForumLinkFormat = string.Empty; this.ForumPage = forumPage; }
/// <summary> /// Unescapes ampersands in the link to the given page. /// </summary> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">if set to <c>true</c> [full URL].</param> /// <returns> /// URL to the given page with unescaped ampersands. /// </returns> public static string GetLinkNotEscaped(ForumPages page, bool fullUrl = false) { return GetLink(page, fullUrl).Replace("&", "&"); }
/// <summary> /// Redirects to the given page. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> public static void Redirect(ForumPages page) { HttpContext.Current.Response.Redirect(GetLinkNotEscaped(page)); }
/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="fullUrl"> /// The full Url. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters. /// </returns> public static string GetLink(ForumPages page, bool fullUrl, string format, params object[] args) { return fullUrl ? YafFactoryProvider.UrlBuilder.BuildUrlFull("g={0}&{1}".FormatWith(page, format.FormatWith(args))) : YafFactoryProvider.UrlBuilder.BuildUrl("g={0}&{1}".FormatWith(page, format.FormatWith(args))); }
/// <summary> /// Redirects to the given page with parameters. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> public static void Redirect(ForumPages page, string format, params object[] args) { HttpContext.Current.Response.Redirect(GetLinkNotEscaped(page, format, args)); }
/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters. /// </returns> public string GetLink(ForumPages page, string format, params object[] args) { return(this.Get <LinkBuilder>().GetLink(page, false, format, args).Replace("&", "&")); }
private bool ValidPage( ForumPages Page ) { if ( LockedForum == 0 ) return true; if ( Page == YAF.Classes.Utils.ForumPages.forum || Page == YAF.Classes.Utils.ForumPages.active || Page == YAF.Classes.Utils.ForumPages.activeusers ) return false; if ( Page == YAF.Classes.Utils.ForumPages.cp_editprofile || Page == YAF.Classes.Utils.ForumPages.cp_pm || Page == YAF.Classes.Utils.ForumPages.cp_message || Page == YAF.Classes.Utils.ForumPages.cp_profile || Page == YAF.Classes.Utils.ForumPages.cp_signature || Page == YAF.Classes.Utils.ForumPages.cp_subscriptions ) return false; if ( Page == YAF.Classes.Utils.ForumPages.pmessage ) return false; return true; }
/// <summary> /// Gets link to the page. /// </summary> /// <param name="boardSettings">The board settings.</param> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">if set to <c>true</c> [full URL].</param> /// <returns> /// URL to the given page. /// </returns> public static string GetLink(YafBoardSettings boardSettings, ForumPages page, bool fullUrl = false) { return(fullUrl ? YafFactoryProvider.UrlBuilder.BuildUrlFull(boardSettings, "g={0}".FormatWith(page)) : YafFactoryProvider.UrlBuilder.BuildUrl(boardSettings, "g={0}".FormatWith(page))); }
/// <summary> /// Gets link to the page. /// </summary> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">if set to <c>true</c> [full URL].</param> /// <returns> /// URL to the given page. /// </returns> public static string GetLink(ForumPages page, bool fullUrl = false) { return fullUrl ? YafFactoryProvider.UrlBuilder.BuildUrlFull("g={0}".FormatWith(page)) : YafFactoryProvider.UrlBuilder.BuildUrl("g={0}".FormatWith(page)); }
/// <summary> /// Redirects to the given page with parameters. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> public void Redirect(ForumPages page, string format, params object[] args) { this.Get <HttpResponseBase>().Redirect(this.Get <LinkBuilder>().GetLink(page, format, args).Replace("&", "&")); }
/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters. /// </returns> public static string GetLink(ForumPages page, string format, params object[] args) { return GetLink(page, false, format, args); }
/// <summary> /// Redirects to the given page with parameters. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> /// <param name="endResponse">True to end the Response, false otherwise.</param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> public void Redirect(ForumPages page, bool endResponse, string format, params object[] args) { this.Get <HttpResponseBase>().Redirect(this.Get <LinkBuilder>().GetLink(page, format, args), endResponse); }
/// <summary> /// Unescapes ampersands in the link to the given page with parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters and unescaped ampersands. /// </returns> public static string GetLinkNotEscaped(ForumPages page, string format, params object[] args) { return GetLink(page, false, format, args).Replace("&", "&"); }
/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="fullUrl"> /// The full Url. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters. /// </returns> public static string GetLink(ForumPages page, bool fullUrl, string format, params object[] args) { return(fullUrl ? YafFactoryProvider.UrlBuilder.BuildUrlFull($"g={page}&{string.Format(format, args)}") : YafFactoryProvider.UrlBuilder.BuildUrl($"g={page}&{string.Format(format, args)}")); }
/// <summary> /// Redirects to the given page with parameters. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> /// <param name="endResponse">True to end the Response, false otherwise.</param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> public static void Redirect(ForumPages page, bool endResponse, string format, params object[] args) { HttpContext.Current.Response.Redirect(GetLinkNotEscaped(page, format, args), endResponse); }
/// <summary> /// Gets link to the page. /// </summary> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">if set to <c>true</c> [full URL].</param> /// <returns> /// URL to the given page. /// </returns> public static string GetLink(ForumPages page, bool fullUrl = false) { return(fullUrl ? YafFactoryProvider.UrlBuilder.BuildUrlFull($"g={page}") : YafFactoryProvider.UrlBuilder.BuildUrl($"g={page}")); }
/// <summary> /// Gets link to the page. /// </summary> /// <param name="boardSettings">The board settings.</param> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">if set to <c>true</c> [full URL].</param> /// <returns> /// URL to the given page. /// </returns> public static string GetLink(BoardSettings boardSettings, ForumPages page, bool fullUrl = false) { return(fullUrl ? FactoryProvider.UrlBuilder.BuildUrlFull(boardSettings, $"g={page}") : FactoryProvider.UrlBuilder.BuildUrl(boardSettings, $"g={page}")); }
/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters. /// </returns> public static string GetLink(ForumPages page, string format, params object[] args) { return(GetLink(page, false, format, args)); }
/// <summary> /// Gets link to the page with given parameters. /// </summary> /// <param name="page"> /// Page to which to create a link. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> /// <returns> /// URL to the given page with parameters. /// </returns> public static string GetLink(ForumPages page, string format, params object[] args) { return(GetLink(page, false, format, args).Replace("&", "&")); }
/// <summary> /// Unescapes ampersands in the link to the given page. /// </summary> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">if set to <c>true</c> [full URL].</param> /// <returns> /// URL to the given page with unescaped ampersands. /// </returns> public static string GetLinkNotEscaped(ForumPages page, bool fullUrl = false) { return(GetLink(page, fullUrl).Replace("&", "&")); }
/// <summary> /// Redirects to the given page with parameters. /// </summary> /// <param name="page"> /// Page to which to redirect response. /// </param> /// <param name="format"> /// Format of parameters. /// </param> /// <param name="args"> /// Array of page parameters. /// </param> public static void Redirect(ForumPages page, string format, params object[] args) { HttpContext.Current.Response.Redirect(GetLink(page, format, args).Replace("&", "&")); }
/// <summary> /// Unescapes ampersands in the link to the given page with parameters. /// </summary> /// <param name="page">Page to which to create a link.</param> /// <param name="fullUrl">if set to <c>true</c> [full URL].</param> /// <param name="format">Format of parameters.</param> /// <param name="args">Array of page parameters.</param> /// <returns> /// URL to the given page with parameters and unescaped ampersands. /// </returns> public static string GetLinkNotEscaped(ForumPages page, bool fullUrl, string format, params object[] args) { return(GetLink(page, fullUrl, format, args).Replace("&", "&")); }
/// <summary> /// Build the url. /// </summary> /// <param name="url">The url.</param> /// <returns> /// Returns the URL. /// </returns> public override string BuildUrl(string url) { string newUrl = "{0}{1}?{2}".FormatWith(AppPath, Config.ForceScriptName ?? ScriptName, url); // create scriptName string scriptName = "{0}{1}".FormatWith(AppPath, Config.ForceScriptName ?? ScriptName); // get the base script file from the config -- defaults to, well, default.aspx :) string scriptFile = Config.BaseScriptFile; if (url.IsNotSet()) { return(newUrl); } if (scriptName.EndsWith(scriptFile)) { string before = scriptName.Remove(scriptName.LastIndexOf(scriptFile, StringComparison.Ordinal)); var parser = new SimpleURLParameterParser(url); // create "rewritten" url... newUrl = before; var useKey = string.Empty; var description = string.Empty; var pageName = parser["g"]; ForumPages forumPage = ForumPages.forum; var getDescription = false; bool isFeed = false; bool handlePage = false; if (pageName.IsSet()) { try { forumPage = pageName.ToEnum <ForumPages>(); getDescription = true; } catch (Exception) { getDescription = false; } } if (getDescription) { switch (forumPage) { case ForumPages.topics: useKey = "f"; pageName += "/"; description = UrlRewriteHelper.GetForumName(parser[useKey].ToType <int>()); handlePage = true; break; case ForumPages.posts: pageName += "/"; if (parser["t"].IsSet()) { useKey = "t"; pageName += "t"; description = UrlRewriteHelper.GetTopicName(parser[useKey].ToType <int>()); } else if (parser["m"].IsSet()) { useKey = "m"; pageName += "m"; try { description = UrlRewriteHelper.GetTopicNameFromMessage(parser[useKey].ToType <int>()); } catch (Exception) { description = "posts"; } } handlePage = true; break; case ForumPages.profile: useKey = "u"; pageName += "/"; description = UrlRewriteHelper.CleanStringForURL( parser["name"].IsSet() ? parser["name"] : UrlRewriteHelper.GetProfileName(parser[useKey].ToType <int>())); parser.Parameters.Remove("name"); break; case ForumPages.forum: pageName = "category/"; if (parser["c"].IsSet()) { useKey = "c"; description = UrlRewriteHelper.GetCategoryName(parser[useKey].ToType <int>()); } else { pageName = string.Empty; } break; case ForumPages.rsstopic: pageName += "/"; if (parser["pg"].IsSet()) { description = parser["pg"].ToEnum <YafRssFeeds>().ToString().ToLower(); } if (parser["f"].IsSet()) { description += "_{0}".FormatWith(UrlRewriteHelper.GetForumName(parser["f"].ToType <int>())); } if (parser["t"].IsSet()) { description += "_{0}".FormatWith(UrlRewriteHelper.GetTopicName(parser["t"].ToType <int>())); } if (parser["c"].IsSet()) { description += "_{0}".FormatWith(UrlRewriteHelper.GetCategoryName(parser["c"].ToType <int>())); } if (parser["ft"].IsSet()) { description += parser["ft"].ToType <int>() == YafSyndicationFormats.Atom.ToInt() ? "-atom" : "-rss"; } handlePage = true; isFeed = true; break; } } // special handling for admin pages if (parser["g"].StartsWith("admin_")) { pageName = parser["g"].Replace("_", "/"); } newUrl += pageName; if (useKey.Length > 0) { newUrl += parser[useKey]; } // handle pager linkse if (handlePage && parser["p"] != null && !isFeed) { var page = parser["p"].ToType <int>(); if (page != 1) { description += "/page{0}".FormatWith(page); } parser.Parameters.Remove("p"); } if (isFeed) { if (parser["ft"] != null) { int page = parser["ft"].ToType <int>(); newUrl += "ft{0}".FormatWith(page); parser.Parameters.Remove("ft"); } if (parser["f"] != null) { int page = parser["f"].ToType <int>(); newUrl += "f{0}".FormatWith(page); parser.Parameters.Remove("f"); } if (parser["t"] != null) { int page = parser["t"].ToType <int>(); newUrl += "t{0}".FormatWith(page); parser.Parameters.Remove("t"); } } if (parser["find"] != null) { newUrl += "find{0}".FormatWith(parser["find"].Trim()); parser.Parameters.Remove("find"); } if (description.Length > 0) { if (description.EndsWith("-")) { description = description.Remove(description.Length - 1, 1); } newUrl += "-{0}".FormatWith(description); } var restURL = parser.CreateQueryString(new[] { "g", useKey }); // append to the url if there are additional (unsupported) parameters if (restURL.Length > 0) { newUrl += "?{0}".FormatWith(restURL); } if (newUrl.EndsWith("/forum")) { // remove in favor of just slash... newUrl = newUrl.Remove(newUrl.LastIndexOf("/forum", StringComparison.Ordinal), "/forum".Length); } // add anchor if (parser.HasAnchor) { newUrl += "#{0}".FormatWith(parser.Anchor); } } // just make sure & is & ... newUrl = newUrl.Replace("&", "&").Replace("&", "&"); return(newUrl); }