public async ValueTask <RedirectResult> Index(string identifier, [FromQuery] string site, [FromQuery] string eventCategory, [FromQuery] string eventAction, [FromQuery] string eventLabel, CancellationToken token) { var query = new ShortUrlQuery(identifier); var result = await _queryBus.QueryAsync(query, token); if (result == null) { return(Redirect("/")); } if (eventCategory != null && eventAction != null && eventLabel != null) { await _googleAnalytics.TrackEventAsync(eventCategory, eventAction, eventLabel, token); } if (!Uri.TryCreate(result.Destination, UriKind.RelativeOrAbsolute, out var uri)) { return(RedirectPermanent(result.Destination)); } if (uri.IsAbsoluteUri) { return(RedirectPermanent(result.Destination)); } var destination = result.Destination; if (site?.Equals("frymo", StringComparison.OrdinalIgnoreCase) == true) { if (destination.Contains("?")) { destination += "&site=frymo"; } else { destination += "?site=frymo"; } } return(RedirectPermanent(destination)); }
public async Task ShortUrlQuery_Ok() { var query = new ShortUrlQuery("pIX5VcMSI"); var _ = await fixture.QueryBus.QueryAsync(query, default); }