From a7b6afb96154a93f20b767d6a9bbce31fd6a95b4 Mon Sep 17 00:00:00 2001 From: Marta Imos-Merska Date: Wed, 6 Sep 2023 17:26:11 +0200 Subject: [PATCH] add missing beginning of string character in regex pattern --- be/src/Unic.UrlMapper2/code/Services/RedirectSearcher.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/be/src/Unic.UrlMapper2/code/Services/RedirectSearcher.cs b/be/src/Unic.UrlMapper2/code/Services/RedirectSearcher.cs index 900f531..6561107 100644 --- a/be/src/Unic.UrlMapper2/code/Services/RedirectSearcher.cs +++ b/be/src/Unic.UrlMapper2/code/Services/RedirectSearcher.cs @@ -96,7 +96,7 @@ 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; } @@ -104,7 +104,7 @@ protected virtual void HandlePreserveQueryString(Redirect redirect, string sourc 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 GetSearchQuery(IProviderSearchContext searchContext, RedirectSearchData redirectSearchData)