Skip to content

Commit 87de5f9

Browse files
committed
Merge branch 'feat/punycode' into chore/all-my-stuffs
# Conflicts: # components.d.ts # package.json # pnpm-lock.yaml # src/tools/index.ts
2 parents a63775f + d087bd9 commit 87de5f9

File tree

5 files changed

+97
-11
lines changed

5 files changed

+97
-11
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"@types/figlet": "^1.5.8",
8383
"@types/markdown-it": "^13.0.7",
8484
"@types/potrace": "^2.1.5",
85+
"@types/punycode": "^2.1.4",
8586
"@vicons/material": "^0.12.0",
8687
"@vicons/tabler": "^0.12.0",
8788
"@vueuse/core": "^10.11.1",
@@ -181,6 +182,7 @@
181182
"plausible-tracker": "^0.3.8",
182183
"pretty-ms": "^9.1.0",
183184
"qpdf-wasm-esm-embedded": "^1.1.1",
185+
"punycode": "^2.3.1",
184186
"qrcode": "^1.5.1",
185187
"randexp": "^0.5.3",
186188
"regex": "^4.3.3",

pnpm-lock.yaml

Lines changed: 14 additions & 11 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { tool as mathOcr } from './math-ocr';
3131
import { tool as markdownTocGenerator } from './markdown-toc-generator';
3232
import { tool as passphraseGenerator } from './passphrase-generator';
3333
import { tool as pinCodeGenerator } from './pin-code-generator';
34+
import { tool as punycodeConverter } from './punycode-converter';
3435

3536
import { tool as cssXpathConverter } from './css-xpath-converter';
3637
import { tool as cssSelectorsMemo } from './css-selectors-memo';
@@ -307,6 +308,7 @@ export const toolsByCategory: ToolCategory[] = [
307308
components: [
308309
ipv4SubnetCalculator,
309310
ipv4AddressConverter,
311+
// ipv6AddressConverter,
310312
ipv4RangeExpander,
311313
macAddressLookup,
312314
macAddressGenerator,
@@ -318,6 +320,7 @@ export const toolsByCategory: ToolCategory[] = [
318320
ipGeoLocation,
319321
macAddressConverter,
320322
ipv6UlaGenerator,
323+
punycodeConverter,
321324
],
322325
},
323326
{

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)