I got a question on how to find the latest version of the Search & Navigation /epi-util/find.js
script file after publishing the article Proxy for Optimizely Search & Navigation tracking script. It is really quite simple, if you look at how Optimiezely does things. The solution is to make use of the built-in IPathHelper
(namespace EPiServer.Find.UI.Helpers
).
IPathHelper pathHelper = ServiceLocator.Current.GetInstance<IPathHelper>();
string basePath = pathHelper.GetClientResourceBasePath();
var baseUri = new Uri(basePath, UriKind.Absolute);
// The base will be something like "https://dl.episerver.net/13.4.5/", but with the latest version number.
var scriptUrl = new Uri(baseUri, "/epi-util/find.js");
Optimizely’s default GetClientResourceBasePath
implementation essentially makes a request to https://dl.episerver.net/version.json which just returns the current version.
{
"currentVersion": "13.4.5"
}