Extending the Optimizely 11 Link Validation job with custom exclude patterns
This might be common knowledge but I have never done this in all my years working with Optimizely solutions.
On a customer I noticed that the link validation scheduled job had been failing for quite some time with the error: The scheme for the url "tel:00 000" in not http or https. So I needed to figure out if and how the configure the job to ignore certain patterns.
It turned out to be quite easy to just create a initialization module that hooked into the options for the job. Code snippet below and complete example on my Gist.
So adding that init module fixed the error and made the job to successfully run.
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class LinkValidatorConfiguration : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
var options = new LinkValidatorOptions();
options.ExcludePatterns.Add(@"^\s*tel:");
options.ExcludePatterns.Add(@"^\s*mailto:");
options.ExcludePatterns.Add(@"^\s*callto:");
options.ExcludePatterns.Add(@"^\s*sms:");
options.ExcludePatterns.Add(@"^\s*javascript:");
options.ExcludePatterns.Add(@"^\s*skype:");
context.Services.AddSingleton(options);
}
public void Initialize(InitializationEngine context) { }
public void Uninitialize(InitializationEngine context) { }
}
Comments