Skip to content

Commit

Permalink
add missing beginning of string character in regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticm committed Sep 6, 2023
1 parent fe492f8 commit a7b6afb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions be/src/Unic.UrlMapper2/code/Services/RedirectSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ protected virtual void HandlePreserveQueryString(Redirect redirect, string sourc
redirect.RegexEnabled = true;
if (!sourceTerm.Contains("?"))
{
redirect.Term = $"{sourceTerm}{Constants.RegularExpressions.QueryStringPattern}$";
redirect.Term = $"^{sourceTerm}{Constants.RegularExpressions.QueryStringPattern}$";
return;
}

var sourceTermPath = sourceTerm.Substring(0, sourceTerm.IndexOf("?", StringComparison.InvariantCultureIgnoreCase));
var addSourceTermQuery = !sourceTerm.EndsWith("?");
var sourceTermQuery = addSourceTermQuery ? sourceTerm.Substring(sourceTerm.IndexOf("?", StringComparison.InvariantCultureIgnoreCase) + 1) : string.Empty;

redirect.Term = $"{sourceTermPath}{(addSourceTermQuery ? $"([?]{sourceTermQuery}{Constants.RegularExpressions.PartialQueryStringPattern})" : Constants.RegularExpressions.QueryStringPattern)}$";
redirect.Term = $"^{sourceTermPath}{(addSourceTermQuery ? $"([?]{sourceTermQuery}{Constants.RegularExpressions.PartialQueryStringPattern})" : Constants.RegularExpressions.QueryStringPattern)}$";
}

protected virtual IQueryable<RedirectSearchResultItem> GetSearchQuery(IProviderSearchContext searchContext, RedirectSearchData redirectSearchData)
Expand Down

0 comments on commit a7b6afb

Please sign in to comment.