public async Task <IActionResult> Index() { ViewBag.InitialUrl = Url.Action(nameof(Start), typeof(RedirectUrlFinderServiceController).ControllerName(), null, Request.Scheme); ViewBag.FinalUrl = await _redirectUrlFinderService.GetRedirectUrlAsync(ViewBag.InitialUrl); return(View()); }
/// <summary> /// URL normalization is the process by which URLs are modified and standardized in a consistent manner. The goal of the normalization process is to transform a URL into a normalized URL so it is possible to determine if two syntactically different URLs may be equivalent. /// https://en.wikipedia.org/wiki/URL_normalization /// </summary> public async Task <string> NormalizeUrlAsync(Uri uri, bool findRedirectUrl) { if (findRedirectUrl) { uri = await _locationFinder.GetRedirectUrlAsync(uri) ?? uri; } var url = urlToLower(uri); url = limitProtocols(url); url = removeDefaultDirectoryIndexes(url); url = removeTheFragment(url); url = removeDuplicateSlashes(url); url = addWww(url); url = removeFeedburnerPart1(url); url = removeFeedburnerPart2(url); return(removeTrailingSlashAndEmptyQuery(url)); }