@@ -79,11 +79,10 @@ private function evaluateTriggerPart(array $triggerPart, $currentPageUrl, $reque
7979class UrlValidatorHelper
8080{
8181 public static function evaluate (array $ triggerPart , $ url ) {
82- if (
83- !array_key_exists ("Operator " , $ triggerPart ) ||
84- !array_key_exists ("IsNegative " , $ triggerPart ) ||
85- !array_key_exists ("IsIgnoreCase " , $ triggerPart ) ||
86- !array_key_exists ("UrlPart " , $ triggerPart )) {
82+ if (!array_key_exists ("Operator " , $ triggerPart ) ||
83+ !array_key_exists ("IsNegative " , $ triggerPart ) ||
84+ !array_key_exists ("IsIgnoreCase " , $ triggerPart ) ||
85+ !array_key_exists ("UrlPart " , $ triggerPart )) {
8786 return false ;
8887 }
8988
@@ -193,12 +192,6 @@ public static function evaluate($opt, $isNegative, $isIgnoreCase, $value, $value
193192 return ComparisonOperatorHelper::equals ($ value , $ valueToCompare , $ isNegative , $ isIgnoreCase );
194193 case "Contains " :
195194 return ComparisonOperatorHelper::contains ($ value , $ valueToCompare , $ isNegative , $ isIgnoreCase );
196- case "StartsWith " :
197- return ComparisonOperatorHelper::startsWith ($ value , $ valueToCompare , $ isNegative , $ isIgnoreCase );
198- case "EndsWith " :
199- return ComparisonOperatorHelper::endsWith ($ value , $ valueToCompare , $ isNegative , $ isIgnoreCase );
200- case "MatchesWith " :
201- return ComparisonOperatorHelper::matchesWith ($ value , $ valueToCompare , $ isNegative , $ isIgnoreCase );
202195 case "EqualsAny " :
203196 return ComparisonOperatorHelper::equalsAny ($ value , $ valuesToCompare , $ isNegative , $ isIgnoreCase );
204197 case "ContainsAny " :
@@ -209,7 +202,7 @@ public static function evaluate($opt, $isNegative, $isIgnoreCase, $value, $value
209202 }
210203
211204 private static function contains ($ value , $ valueToCompare , $ isNegative , $ ignoreCase ) {
212- if ($ valueToCompare === "* " ) {
205+ if ($ valueToCompare === "* " && !Utils:: isNullOrEmptyString ( $ value ) ) {
213206 return true ;
214207 }
215208
@@ -218,6 +211,7 @@ private static function contains($value, $valueToCompare, $isNegative, $ignoreCa
218211 $ valueToCompare = strtoupper ($ valueToCompare );
219212 }
220213 $ evaluation = strpos ($ value , $ valueToCompare ) !== false ;
214+
221215 if ($ isNegative ) {
222216 return !$ evaluation ;
223217 } else {
@@ -256,60 +250,4 @@ private static function containsAny($value,array $valuesToCompare, $isNegative,
256250 }
257251 return $ isNegative ;
258252 }
259-
260- private static function endsWith ($ value , $ valueToCompare , $ isNegative , $ ignoreCase ) {
261- if ($ ignoreCase ) {
262- $ value = strtoupper ($ value );
263- $ valueToCompare = strtoupper ($ valueToCompare );
264- }
265- $ evaluation = false ;
266- $ rLength = strlen ($ valueToCompare );
267- if ($ rLength === 0 ) {
268- $ evaluation = true ;
269- } else {
270- $ evaluation = substr ($ value , -$ rLength ) === $ valueToCompare ;
271- }
272-
273- if ($ isNegative ) {
274- return !$ evaluation ;
275- } else {
276- return $ evaluation ;
277- }
278- }
279-
280- private static function startsWith ($ value , $ valueToCompare , $ isNegative , $ ignoreCase ) {
281- if ($ ignoreCase ) {
282- $ value = strtoupper ($ value );
283- $ valueToCompare = strtoupper ($ valueToCompare );
284- }
285- $ evaluation = false ;
286-
287- $ rLength = strlen ($ valueToCompare );
288- $ evaluation = (substr ($ value , 0 , $ rLength ) === $ valueToCompare );
289-
290- if ($ isNegative ) {
291- return !$ evaluation ;
292- } else {
293- return $ evaluation ;
294- }
295- }
296-
297- private static function matchesWith ($ value , $ valueToCompare , $ isNegative , $ ignoreCase ) {
298- if ($ ignoreCase ) {
299- $ value = strtoupper ($ value );
300- $ valueToCompare = strtoupper ($ valueToCompare );
301- }
302-
303- if (preg_match ($ valueToCompare , $ value )) {
304- $ evaluation = true ;
305- } else {
306- $ evaluation = false ;
307- }
308-
309- if ($ isNegative ) {
310- return !$ evaluation ;
311- } else {
312- return $ evaluation ;
313- }
314- }
315253}
0 commit comments