Skip to content

Commit d087bd9

Browse files
committed
feat(new tool): Punycode Converter
Fix CorentinTh#1235
1 parent 318fb6e commit d087bd9

File tree

6 files changed

+113
-22
lines changed

6 files changed

+113
-22
lines changed

components.d.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,23 @@ declare module '@vue/runtime-core' {
132132
NCode: typeof import('naive-ui')['NCode']
133133
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
134134
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
135+
NDivider: typeof import('naive-ui')['NDivider']
135136
NEllipsis: typeof import('naive-ui')['NEllipsis']
136-
NForm: typeof import('naive-ui')['NForm']
137-
NFormItem: typeof import('naive-ui')['NFormItem']
138137
NH1: typeof import('naive-ui')['NH1']
139138
NH3: typeof import('naive-ui')['NH3']
140139
NIcon: typeof import('naive-ui')['NIcon']
141-
NInputNumber: typeof import('naive-ui')['NInputNumber']
142140
NLayout: typeof import('naive-ui')['NLayout']
143141
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
144142
NMenu: typeof import('naive-ui')['NMenu']
145143
NScrollbar: typeof import('naive-ui')['NScrollbar']
146-
NSlider: typeof import('naive-ui')['NSlider']
147-
NSwitch: typeof import('naive-ui')['NSwitch']
148144
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
149145
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
150146
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
151147
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default']
152148
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
153149
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
154150
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
151+
PunycodeConverter: typeof import('./src/tools/punycode-converter/punycode-converter.vue')['default']
155152
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
156153
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
157154
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@tiptap/starter-kit": "2.1.6",
4343
"@tiptap/vue-3": "2.0.3",
4444
"@types/figlet": "^1.5.8",
45+
"@types/punycode": "^2.1.4",
4546
"@vicons/material": "^0.12.0",
4647
"@vicons/tabler": "^0.12.0",
4748
"@vueuse/core": "^10.3.0",
@@ -81,6 +82,7 @@
8182
"pdf-signature-reader": "^1.4.2",
8283
"pinia": "^2.0.34",
8384
"plausible-tracker": "^0.3.8",
85+
"punycode": "^2.3.1",
8486
"qrcode": "^1.5.1",
8587
"sql-formatter": "^13.0.0",
8688
"ua-parser-js": "^1.0.35",

pnpm-lock.yaml

Lines changed: 20 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
22
import { tool as base64StringConverter } from './base64-string-converter';
33
import { tool as basicAuthGenerator } from './basic-auth-generator';
44
import { tool as emailNormalizer } from './email-normalizer';
5+
import { tool as punycodeConverter } from './punycode-converter';
56

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

@@ -158,7 +159,16 @@ export const toolsByCategory: ToolCategory[] = [
158159
},
159160
{
160161
name: 'Network',
161-
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
162+
components: [
163+
ipv4SubnetCalculator,
164+
ipv4AddressConverter,
165+
// ipv6AddressConverter,
166+
ipv4RangeExpander,
167+
macAddressLookup,
168+
macAddressGenerator,
169+
ipv6UlaGenerator,
170+
punycodeConverter,
171+
],
162172
},
163173
{
164174
name: 'Math',

src/tools/punycode-converter/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { World } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Punycode Converter',
6+
path: '/punycode-converter',
7+
description: 'Convert international unicode domain names or emails from/to ASCII Punycode version',
8+
keywords: ['punycode', 'converter', 'rfc3492', 'bootstring', 'domain', 'dns'],
9+
component: () => import('./punycode-converter.vue'),
10+
icon: World,
11+
createdAt: new Date('2024-08-15'),
12+
});
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<script setup lang="ts">
2+
import { toASCII, toUnicode } from 'punycode/';
3+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
4+
5+
const punycodeInput = ref('');
6+
const intlOutput = computed(
7+
() => {
8+
try {
9+
return toUnicode(punycodeInput.value?.trim());
10+
}
11+
catch (e: any) {
12+
return e.toString();
13+
}
14+
},
15+
);
16+
17+
const intlInput = ref('');
18+
const punycodeOutput = computed(
19+
() => {
20+
try {
21+
return toASCII(intlInput.value?.trim());
22+
}
23+
catch (e: any) {
24+
return e.toString();
25+
}
26+
},
27+
);
28+
</script>
29+
30+
<template>
31+
<div max-w-600>
32+
<c-card title="Punycode to International">
33+
<c-input-text
34+
v-model:value="punycodeInput"
35+
placeholder="Put your punycode domain name or email to decode..."
36+
label="Punycode Domain name/Email"
37+
raw-text
38+
/>
39+
40+
<n-divider />
41+
42+
<TextareaCopyable
43+
label="Decoded Domain name/Email"
44+
:value="intlOutput"
45+
readonly
46+
/>
47+
</c-card>
48+
49+
<c-card title="International to Punycode" mt-5>
50+
<c-input-text
51+
v-model:value="intlInput"
52+
placeholder="Put your international domain or email name here..."
53+
label="Domain name or email to encode"
54+
raw-text
55+
/>
56+
57+
<n-divider />
58+
59+
<TextareaCopyable
60+
label="Punycode Domain name/Email"
61+
:value="punycodeOutput"
62+
readonly
63+
/>
64+
</c-card>
65+
</div>
66+
</template>

0 commit comments

Comments
 (0)