Skip to content

Commit

Permalink
Merge pull request #30 from unic/feature/get_fields_by_id_not_name
Browse files Browse the repository at this point in the history
feat: ensure that fields are identified by ID not name
  • Loading branch information
chaoticm authored Apr 16, 2024
2 parents 85e8c3c + 3bf5362 commit e560ca3
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class PreserveQueryStringComputedField : UrlMapperComputedFieldBase
{
protected override object Compute(IIndexable indexable)
{
var value = indexable?.GetFieldByName(Constants.Fields.Redirect.PreserveQueryString)?.Value;
var value = indexable?.GetFieldById(Constants.Fields.Redirect.PreserveQueryString)?.Value;

return MainUtil.GetBool(value, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override object Compute(IIndexable indexable)
{
var item = (Item)(indexable as SitecoreIndexableItem);

var value = indexable?.GetFieldByName(Constants.Fields.Redirect.RedirectType)?.Value;
var value = indexable?.GetFieldById(Constants.Fields.Redirect.RedirectType)?.Value;
if (ID.TryParse(value, out var specificationId))
{
return this.ResolveDependency<ISpecificationService>().GetSharedSpecification(item.Database, specificationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class RegexEnabledComputedField : UrlMapperComputedFieldBase
{
protected override object Compute(IIndexable indexable)
{
var value = indexable?.GetFieldByName(Constants.Fields.Redirect.RegexEnabled)?.Value;
var value = indexable?.GetFieldById(Constants.Fields.Redirect.RegexEnabled)?.Value;
return MainUtil.GetBool(value, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override object Compute(IIndexable indexable)
{
var item = (Item)(indexable as SitecoreIndexableItem);

var value = indexable?.GetFieldByName(Constants.Fields.Redirect.SourceProtocol)?.Value;
var value = indexable?.GetFieldById(Constants.Fields.Redirect.SourceProtocol)?.Value;
if (ID.TryParse(value, out var specificationId))
{
var protocol = this.ResolveDependency<ISpecificationService>().GetSharedSpecification(item.Database, specificationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class SourceTermComputedField : UrlMapperComputedFieldBase
{
protected override object Compute(IIndexable indexable)
{
var value = indexable?.GetFieldByName(Constants.Fields.Redirect.SourceTerm)?.Value as string;
var value = indexable?.GetFieldById(Constants.Fields.Redirect.SourceTerm)?.Value as string;

return string.IsNullOrWhiteSpace(value)
? default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
[UsedImplicitly]
public class TargetUrlComputedField : UrlMapperComputedFieldBase
{
protected override object Compute(IIndexable indexable) => indexable?.GetFieldByName(Constants.Fields.Redirect.Target)?.Value;
protected override object Compute(IIndexable indexable) => indexable?.GetFieldById(Constants.Fields.Redirect.Target)?.Value;
}
}
12 changes: 6 additions & 6 deletions be/src/Unic.UrlMapper2/code/Definitions/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public struct Fields
{
public struct Redirect
{
public const string SourceTerm = "Source Term";
public static readonly ID SourceTerm = ID.Parse("{BF458D1E-59C8-4661-9AD0-67A95CB85785}");

public const string Target = "Target";
public static readonly ID Target = ID.Parse("{B64E1624-9590-4CAD-B3B6-802F4C794086}");

public const string RedirectType = "Redirect Type";
public static readonly ID RedirectType = ID.Parse("{BB67D28D-EFF1-4A65-BD01-DE64AC6E9DA4}");

public const string SourceProtocol = "Source Protocol";
public static readonly ID SourceProtocol = ID.Parse("{E453D759-43E3-4033-ADA8-245DDB56980D}");

public const string RegexEnabled = "Regex enabled";
public static readonly ID RegexEnabled = ID.Parse("{A21DADDF-E5B1-4134-B236-9515D9153EF6}");

public const string PreserveQueryString = "Preserve Query String";
public static readonly ID PreserveQueryString = ID.Parse("{A9D3D444-C009-4C90-B1A2-F8C25D28D084}");
}

public struct Specification
Expand Down
4 changes: 2 additions & 2 deletions be/src/Unic.UrlMapper2/code/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.3.3.0")]
[assembly: AssemblyFileVersion("1.3.3.0")]
[assembly: AssemblyVersion("1.3.4.0")]
[assembly: AssemblyFileVersion("1.3.4.0")]
2 changes: 1 addition & 1 deletion build/sif-configs/Prerequisites.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"WebPlatformDownload": {
"Type": "String",
"Description": "Download location of Microsoft Web Platform Installer 5.0",
"DefaultValue": "https://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi"
"DefaultValue": "https://download.microsoft.com/download/8/4/9/849DBCF2-DFD9-49F5-9A19-9AEE5B29341A/WebPlatformInstaller_x64_en-US.msi"
},
"SQLClrTypesx86Download": {
"Type": "String",
Expand Down

0 comments on commit e560ca3

Please sign in to comment.