public async Task <RedirectUrl> GetByShortenedUrlAsync(string shortenedUrl, string languageCode) { var absolutePath = new Uri(shortenedUrl).AbsolutePath.Replace("/", ""); var url = await _urlService.GetByShortenedUrlAsync(absolutePath, languageCode); if (url == null) { throw new InvalidOperationException($"Could not find any match for {shortenedUrl}."); } return(new RedirectUrl { Url = url.TargetUrl }); }