Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update evaluate-reward-conditions.ts

Kiran K8b30a7c0d95a
diff --git a/apps/web/lib/partners/evaluate-reward-conditions.ts b/apps/web/lib/partners/evaluate-reward-conditions.ts
index f41ed729fe..6f08136c5f 100644
--- a/apps/web/lib/partners/evaluate-reward-conditions.ts
+++ b/apps/web/lib/partners/evaluate-reward-conditions.ts
@@ -124,23 +124,27 @@ const evaluateCondition = ({
// Starts with
if (condition.operator === "starts_with") {
- if (typeof fieldValue !== "string" || typeof condition.value !== "string") {
+ if (
+ typeof fieldValue !== "string" ||
+ typeof condition.value !== "string" ||
+ condition.value === ""
+ ) {
return false;
}
- if (condition.value === "") return false;
-
return fieldValue.startsWith(condition.value);
}
// Ends with
if (condition.operator === "ends_with") {
- if (typeof fieldValue !== "string" || typeof condition.value !== "string") {
+ if (
+ typeof fieldValue !== "string" ||
+ typeof condition.value !== "string" ||
+ condition.value === ""
+ ) {
return false;
}
- if (condition.value === "") return false;
-
return fieldValue.endsWith(condition.value);
}
@@ -150,10 +154,13 @@ const evaluateCondition = ({
return false;
}
- const needle = condition.value.trim();
- if (needle === "") return false;
+ const trimmedValue = condition.value.trim();
+
+ if (trimmedValue === "") {
+ return false;
+ }
- return String(fieldValue).includes(needle);
+ return String(fieldValue).includes(trimmedValue);
}
// Not contains
@@ -162,10 +169,13 @@ const evaluateCondition = ({
return false;
}
- const needle = condition.value.trim();
- if (needle === "") return false;
+ const trimmedValue = condition.value.trim();
+
+ if (trimmedValue === "") {
+ return false;
+ }
- return !String(fieldValue).includes(needle);
+ return !String(fieldValue).includes(trimmedValue);
}
// In