aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-07-23 19:09:22 +0200
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-07-23 19:09:22 +0200
commit92ce419f45e110509ab202485a36bf175ce345da (patch)
tree96bdd1deb01614df93c5b01c4e78075acf41cb0c /src
parent394d085846d976219ea775c21cd7e77f0f72a12b (diff)
downloadit-tools-92ce419f45e110509ab202485a36bf175ce345da.tar.gz
it-tools-92ce419f45e110509ab202485a36bf175ce345da.tar.zst
it-tools-92ce419f45e110509ab202485a36bf175ce345da.zip
fix(text-statistics): empty text mean 0 words and 0 lines
Diffstat (limited to 'src')
-rw-r--r--src/tools/text-statistics/text-statistics.vue10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tools/text-statistics/text-statistics.vue b/src/tools/text-statistics/text-statistics.vue
index ad11d0e..84d4a52 100644
--- a/src/tools/text-statistics/text-statistics.vue
+++ b/src/tools/text-statistics/text-statistics.vue
@@ -5,19 +5,17 @@
<br />
<n-space justify="space-around">
<n-statistic label="Character count" :value="text.length" />
- <n-statistic label="Word count" :value="text.split(/\s+/).length" />
- <n-statistic label="Line count" :value="text.split(/\r\n|\r|\n/).length" />
+ <n-statistic label="Word count" :value="text === '' ? 0 : text.split(/\s+/).length" />
+ <n-statistic label="Line count" :value="text === '' ? 0 : text.split(/\r\n|\r|\n/).length" />
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" />
</n-space>
</n-card>
</template>
<script setup lang="ts">
-import { ref } from 'vue';
import { formatBytes } from '@/utils/convert';
+import { ref } from 'vue';
import { getStringSizeInBytes } from './text-statistics.service';
-const text = ref(
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Commodo risus faucibus varius volutpat habitasse suspendisse justo inceptos primis mi. Fusce molestie lorem bibendum habitasse litora adipiscing turpis egestas quis nec. Non id conubia vulputate etiam iaculis vitae venenatis hac fusce condimentum. Adipiscing pellentesque venenatis ornare pulvinar tempus hac montes velit erat convallis.',
-);
+const text = ref('');
</script>