Skip to content

Commit

Permalink
🐛 fix(PageTabs): self regular expression wasn't set on init (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem authored Jul 16, 2024
1 parent a1ac3d5 commit 4ed328b
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ public class PatternPathComponentBase : MasaComponentBase

protected HashSet<Regex> CachedSelfPatternRegexes = new();

protected override void OnInitialized()
{
base.OnInitialized();

UpsertCachedSelfPatternRegexes();
}

protected override void OnParametersSet()
{
base.OnParametersSet();

if (_prevSelfPatterns.SetEquals(SelfPatterns)) return;

_prevSelfPatterns = new HashSet<string>(SelfPatterns);
CachedSelfPatternRegexes =
new HashSet<Regex>(SelfPatterns.Select(p => new Regex(p, RegexOptions.IgnoreCase)));
UpsertCachedSelfPatternRegexes();
}

protected virtual PatternPath GetCurrentPatternPath()
Expand All @@ -38,4 +41,12 @@ protected virtual PatternPath GetCurrentPatternPath()
? new PatternPath(absolutePath)
: new PatternPath(selfPatternRegex.ToString(), absolutePath);
}

private void UpsertCachedSelfPatternRegexes()
{
if (_prevSelfPatterns.SetEquals(SelfPatterns)) return;

_prevSelfPatterns = [..SelfPatterns];
CachedSelfPatternRegexes = [..SelfPatterns.Select(p => new Regex(p, RegexOptions.IgnoreCase))];
}
}

0 comments on commit 4ed328b

Please sign in to comment.