From 8af91d9673fff3aeba8a770d45a4a096c78b5657 Mon Sep 17 00:00:00 2001
From: Hazelnoot <acomputerdog@gmail.com>
Date: Wed, 5 Feb 2025 09:50:18 -0500
Subject: extract variable hasExistingDefaultCW to improve code readability

---
 packages/frontend/src/components/MkPostForm.vue | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'packages/frontend/src/components/MkPostForm.vue')

diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue
index 935915cf31..4ef54c8971 100644
--- a/packages/frontend/src/components/MkPostForm.vue
+++ b/packages/frontend/src/components/MkPostForm.vue
@@ -374,7 +374,8 @@ if ($i.defaultCW) {
 		// This is a fancy way of simulating /\bsearch\b/ without a regular expression.
 		// We're checking to see whether the default CW appears inside the existing CW, but *only* if there's word boundaries.
 		const parts = cw.value.split($i.defaultCW);
-		if (parts.length !== 2 || /\w$/.test(parts[0]) || /^\w/.test(parts[1])) {
+		const hasExistingDefaultCW = parts.length === 0 && !/\w$/.test(parts[0]) && !/^\w/.test(parts[1]);
+		if (!hasExistingDefaultCW) {
 			// We need to merge the CWs
 			if ($i.defaultCWPriority === 'defaultParent') {
 				cw.value = `${$i.defaultCW}, ${cw.value}`;
-- 
cgit v1.2.3-freya

