Skip to content

Commit

Permalink
Merge pull request #39 from episerver/bugfix/MAR-1517-Conversion-is-n…
Browse files Browse the repository at this point in the history
…ot-counted-properly-for-start-page

fix conversion test not count for start page url without language segment
  • Loading branch information
Tson-optimizely authored Jul 25, 2023
2 parents 1eae972 + 8dff97d commit 3cb2427
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/EPiServer.Marketing.KPI/Common/ContentComparatorKPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ContentComparatorKPI : Kpi
public List<string> _startpagepaths = new List<string>();
private ObjectCache _cache;
private readonly Injected<IKpiHelper> _kpiHelper;
private readonly Injected<IUrlResolver> _IUrlResolver;
private readonly Injected<IUrlResolver> _urlResolver;
private readonly Injected<IContentRepository> _contentRepository;
private readonly Injected<IContentVersionRepository> _contentVersionRepository;
private readonly Injected<IContentEvents> _contentEvents;
Expand Down Expand Up @@ -74,7 +74,7 @@ public override string UiReadOnlyMarkup
var conversionDescription = LocalizationService.Current.GetString("/kpi/content_comparator_kpi/readonly_markup/conversion_selector_description");

var conversionContent = _contentRepository.Service.Get<IContent>(ContentGuid);
var conversionLink = _IUrlResolver.Service.GetUrl(conversionContent.ContentLink);
var conversionLink = _urlResolver.Service.GetUrl(conversionContent.ContentLink);
markup = string.Format(markup, conversionDescription, conversionLink,
conversionContent.Name);
}
Expand Down Expand Up @@ -137,9 +137,15 @@ public override IKpiResult Evaluate(object sender, EventArgs e)
retval = _startpagepaths.Any(path => path.Trim('/')
.Equals(_kpiHelper.Service.GetRequestPath().Trim('/'), StringComparison.OrdinalIgnoreCase))
&& ContentGuid.Equals(ea.Content.ContentGuid);

// Special case: Start page contain url that has no language segment in multilingual site
if (_kpiHelper.Service.GetRequestPath().Equals("/") && ContentGuid.Equals(ea.Content.ContentGuid))
{
retval = true;
}
}
else
{
{
//We need to make sure the content being evaluated is the actual content being requested
//Addresses MAR-1226
retval = (_kpiHelper.Service.GetUrl(_content.ContentLink).ToLower().Trim('/') == _kpiHelper.Service.GetRequestPath().ToLower().Trim('/')
Expand Down

0 comments on commit 3cb2427

Please sign in to comment.