Skip to content

Commit

Permalink
fix: adds condition to handle legacy and current portal URL structure…
Browse files Browse the repository at this point in the history
…s and adds null check for getting list types in basic config helper methods
  • Loading branch information
ndorin committed Aug 26, 2024
1 parent 941e537 commit 90251d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/PepperDash.Essentials.Core/Config/BasicConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public BasicConfig()
/// </summary>
public Dictionary<string, SourceListItem> GetSourceListForKey(string key)
{
if (string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key))
if (SourceLists == null || string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key))
return null;

return SourceLists[key];
Expand All @@ -68,7 +68,7 @@ public Dictionary<string, SourceListItem> GetSourceListForKey(string key)
/// <returns>DestinationList if the key exists, null otherwise</returns>
public Dictionary<string, DestinationListItem> GetDestinationListForKey(string key)
{
if (string.IsNullOrEmpty(key) || !DestinationLists.ContainsKey(key))
if (DestinationLists == null || string.IsNullOrEmpty(key) || !DestinationLists.ContainsKey(key))
{
return null;
}
Expand All @@ -83,7 +83,7 @@ public Dictionary<string, DestinationListItem> GetDestinationListForKey(string k
/// <returns>AudioControlPointList if the key exists, null otherwise</returns>
public AudioControlPointListItem GetAudioControlPointListForKey(string key)
{
if (string.IsNullOrEmpty(key) || !AudioControlPointLists.ContainsKey(key))
if (AudioControlPointLists == null || string.IsNullOrEmpty(key) || !AudioControlPointLists.ContainsKey(key))
return null;

return AudioControlPointLists[key];
Expand All @@ -94,7 +94,7 @@ public AudioControlPointListItem GetAudioControlPointListForKey(string key)
/// </summary>
public Dictionary<string, CameraListItem> GetCameraListForKey(string key)
{
if (string.IsNullOrEmpty(key) || !CameraLists.ContainsKey(key))
if (CameraLists == null || string.IsNullOrEmpty(key) || !CameraLists.ContainsKey(key))
return null;

return CameraLists[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ public string SystemUuid
if (string.IsNullOrEmpty(SystemUrl))
return "missing url";

var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
string uuid = result.Groups[1].Value;
return uuid;
if (SystemUrl.Contains("#"))
{
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
string uuid = result.Groups[1].Value;
return uuid;
} else
{
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/.*");
string uuid = result.Groups[1].Value;
return uuid;
}
}
}

Expand All @@ -44,10 +52,18 @@ public string TemplateUuid
{
if (string.IsNullOrEmpty(TemplateUrl))
return "missing template url";

var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
string uuid = result.Groups[1].Value;
return uuid;

if (TemplateUrl.Contains("#"))
{
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
string uuid = result.Groups[1].Value;
return uuid;
} else
{
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/(.*)\/system-template-versions\/(.*)\/.*");
string uuid = result.Groups[2].Value;
return uuid;
}
}
}

Expand Down

0 comments on commit 90251d9

Please sign in to comment.