Skip to content

Commit

Permalink
feat(new-tool): add email normalizer (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinTh committed Aug 15, 2024
1 parent f1a5489 commit 318fb6e
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ declare module '@vue/runtime-core' {
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
EmailNormalizer: typeof import('./src/tools/email-normalizer/email-normalizer.vue')['default']
EmojiCard: typeof import('./src/tools/emoji-picker/emoji-card.vue')['default']
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
EmojiPicker: typeof import('./src/tools/emoji-picker/emoji-picker.vue')['default']
Expand Down Expand Up @@ -132,13 +133,18 @@ declare module '@vue/runtime-core' {
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSlider: typeof import('naive-ui')['NSlider']
NSwitch: typeof import('naive-ui')['NSwitch']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"crypto-js": "^4.1.1",
"date-fns": "^2.29.3",
"dompurify": "^3.0.6",
"email-normalizer": "^1.0.0",
"emojilib": "^3.0.10",
"figlet": "^1.7.0",
"figue": "^1.2.0",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions src/tools/email-normalizer/email-normalizer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script setup lang="ts">
import { normalizeEmail } from 'email-normalizer';
import { withDefaultOnError } from '@/utils/defaults';
import { useCopy } from '@/composable/copy';
const emails = ref('');
const normalizedEmails = computed(() => {
if (!emails.value) {
return '';
}
return emails.value
.split('\n')
.map((email) => {
return withDefaultOnError(() => normalizeEmail({ email }), `Unable to parse email: ${email}`);
})
.join('\n');
});
const { copy } = useCopy({ source: normalizedEmails, text: 'Normalized emails copied to the clipboard', createToast: true });
</script>

<template>
<div>
<div class="mb-2">
Raw emails to normalize:
</div>
<c-input-text
v-model:value="emails"
placeholder="Put your emails here (one per line)..."
rows="3"
multiline
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
autofocus
monospace
/>

<div class="mb-2 mt-4">
Normalized emails:
</div>
<c-input-text
:value="normalizedEmails"
placeholder="Normalized emails will appear here..."
rows="3"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
multiline
readonly
monospace
/>
<div class="mt-4 flex justify-center gap-2">
<c-button @click="emails = ''">
Clear emails
</c-button>
<c-button :disabled="!normalizedEmails" @click="copy()">
Copy normalized emails
</c-button>
</div>
</div>
</template>
12 changes: 12 additions & 0 deletions src/tools/email-normalizer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Mail } from '@vicons/tabler';
import { defineTool } from '../tool';

export const tool = defineTool({
name: 'Email normalizer',
path: '/email-normalizer',
description: 'Normalize email addresses to a standard format for easier comparison. Useful for deduplication and data cleaning.',
keywords: ['email', 'normalizer'],
component: () => import('./email-normalizer.vue'),
icon: Mail,
createdAt: new Date('2024-08-15'),
});
2 changes: 2 additions & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as emailNormalizer } from './email-normalizer';

import { tool as asciiTextDrawer } from './ascii-text-drawer';

Expand Down Expand Up @@ -152,6 +153,7 @@ export const toolsByCategory: ToolCategory[] = [
dockerRunToDockerComposeConverter,
xmlFormatter,
yamlViewer,
emailNormalizer,
],
},
{
Expand Down

0 comments on commit 318fb6e

Please sign in to comment.