summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkPostForm.vue
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-02-05 09:50:18 -0500
committerHazelnoot <acomputerdog@gmail.com>2025-02-05 14:22:50 -0500
commit8af91d9673fff3aeba8a770d45a4a096c78b5657 (patch)
tree4618ff7ac0411078e2d473593e7ef815e9267778 /packages/frontend/src/components/MkPostForm.vue
parentapply default content warning to new posts (diff)
downloadsharkey-8af91d9673fff3aeba8a770d45a4a096c78b5657.tar.gz
sharkey-8af91d9673fff3aeba8a770d45a4a096c78b5657.tar.bz2
sharkey-8af91d9673fff3aeba8a770d45a4a096c78b5657.zip
extract variable hasExistingDefaultCW to improve code readability
Diffstat (limited to 'packages/frontend/src/components/MkPostForm.vue')
-rw-r--r--packages/frontend/src/components/MkPostForm.vue3
1 files changed, 2 insertions, 1 deletions
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}`;