World is now on Opti ID! Learn more

Troubles with Unified Search/Track - Shortcut redirection

Vote:
 

Hi,

I have an issue in Unified Search when using Track(). If I open a search result that is a shortcut that redirects to a different url, and the search string contains Norwegian letters ('æ', 'ø' or 'å'), then I get an error, telling me it's not allowed with these characters in the header.

I wonder if there are some issues with Track()? And I cannot find a built-in way to make sure the url is encoded.

I made this code to fix the problem, but I'm thinking this probably shouldn't be necessary:

	public void EncodeSearchQueryParameter(UnifiedSearchHit searchHit)
	{
		if (string.IsNullOrWhiteSpace(searchHit.Url)) return;
		
		var uri = new Uri(searchHit.Url);
		var query = HttpUtility.ParseQueryString(uri.Query);

		var originalQuery = query["_t_q"];
		if (!string.IsNullOrEmpty(originalQuery))
		{
			query["_t_q"] = Uri.EscapeDataString(originalQuery);
		}

		var baseUrl = uri.GetLeftPart(UriPartial.Path);
		var newQuery = query.ToString();
		var newUrl = $"{baseUrl}?{newQuery}";
		
		searchHit.Url = newUrl;
	}
#338546
May 22, 2025 15:00
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.