diff --git a/package-lock.json b/package-lock.json
index 109818cd..f413d674 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -30,6 +30,7 @@
"p-retry": "~6.2.0",
"p-throttle": "~6.1.0",
"preact": "~10.20.1",
+ "punycode": "~2.3.1",
"react-hotkeys-hook": "~4.5.0",
"react-intersection-observer": "~9.8.1",
"react-quick-pinch-zoom": "~5.1.0",
@@ -7154,11 +7155,9 @@
"integrity": "sha512-8xuCeM3l8yqdmbPoYeLbrAXCBWu19XEYc5/F28f5qOaoAIMyfmBUkl5axiK+x9olUvRlcekvnm98AP9RDngOIw=="
},
"node_modules/punycode": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz",
- "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==",
- "dev": true,
- "license": "MIT",
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
+ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"engines": {
"node": ">=6"
}
diff --git a/package.json b/package.json
index 665c6228..35091075 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"p-retry": "~6.2.0",
"p-throttle": "~6.1.0",
"preact": "~10.20.1",
+ "punycode": "~2.3.1",
"react-hotkeys-hook": "~4.5.0",
"react-intersection-observer": "~9.8.1",
"react-quick-pinch-zoom": "~5.1.0",
diff --git a/src/components/account-info.jsx b/src/components/account-info.jsx
index af9aed35..047e75bd 100644
--- a/src/components/account-info.jsx
+++ b/src/components/account-info.jsx
@@ -9,6 +9,7 @@ import {
useRef,
useState,
} from 'preact/hooks';
+import punycode from 'punycode';
import { api } from '../utils/api';
import enhanceContent from '../utils/enhance-content';
@@ -228,7 +229,7 @@ function AccountInfo({
const accountInstance = useMemo(() => {
if (!url) return null;
- const domain = new URL(url).hostname;
+ const domain = punycode.toUnicode(new URL(url).hostname);
return domain;
}, [url]);
@@ -1598,7 +1599,7 @@ function niceAccountURL(url) {
const path = pathname.replace(/\/$/, '').replace(/^\//, '');
return (
<>
- {host}/
+ {punycode.toUnicode(host)}/
{path}
>
diff --git a/src/components/status.jsx b/src/components/status.jsx
index d4e66a5a..6ce567c4 100644
--- a/src/components/status.jsx
+++ b/src/components/status.jsx
@@ -20,6 +20,7 @@ import {
useRef,
useState,
} from 'preact/hooks';
+import punycode from 'punycode';
import { useHotkeys } from 'react-hotkeys-hook';
import { useLongPress } from 'use-long-press';
import { useSnapshot } from 'valtio';
@@ -2231,9 +2232,9 @@ function Card({ card, selfReferential, instance }) {
);
if (hasText && (image || (type === 'photo' && blurhash))) {
- const domain = new URL(url).hostname
- .replace(/^www\./, '')
- .replace(/\/$/, '');
+ const domain = punycode.toUnicode(
+ new URL(url).hostname.replace(/^www\./, '').replace(/\/$/, ''),
+ );
let blurhashImage;
const rgbAverageColor =
image && blurhash ? getBlurHashAverageColor(blurhash) : null;
@@ -2349,7 +2350,9 @@ function Card({ card, selfReferential, instance }) {
// );
}
if (hasText && !image) {
- const domain = new URL(url).hostname.replace(/^www\./, '');
+ const domain = punycode.toUnicode(
+ new URL(url).hostname.replace(/^www\./, ''),
+ );
return (
- {host}
+ {punycode.toUnicode(host)}
{username ? (
<>
/{username}
diff --git a/src/pages/account-statuses.jsx b/src/pages/account-statuses.jsx
index 7cbe0878..e91e8fa6 100644
--- a/src/pages/account-statuses.jsx
+++ b/src/pages/account-statuses.jsx
@@ -6,6 +6,7 @@ import {
useRef,
useState,
} from 'preact/hooks';
+import punycode from 'punycode';
import { useParams, useSearchParams } from 'react-router-dom';
import { useSnapshot } from 'valtio';
@@ -516,7 +517,13 @@ function AccountStatuses() {
>
{' '}
{!sameCurrentInstance && (
diff --git a/src/pages/catchup.jsx b/src/pages/catchup.jsx
index dae394d3..9a5f318c 100644
--- a/src/pages/catchup.jsx
+++ b/src/pages/catchup.jsx
@@ -13,6 +13,7 @@ import {
useRef,
useState,
} from 'preact/hooks';
+import punycode from 'punycode';
import { useHotkeys } from 'react-hotkeys-hook';
import { useSearchParams } from 'react-router-dom';
import { uid } from 'uid/single';
@@ -1099,9 +1100,11 @@ function Catchup() {
height,
publishedAt,
} = card;
- const domain = new URL(url).hostname
- .replace(/^www\./, '')
- .replace(/\/$/, '');
+ const domain = punycode.toUnicode(
+ new URL(url).hostname
+ .replace(/^www\./, '')
+ .replace(/\/$/, ''),
+ );
let accentColor;
if (blurhash) {
const averageColor = getBlurHashAverageColor(blurhash);
diff --git a/src/pages/status.jsx b/src/pages/status.jsx
index fe638371..7960a5ba 100644
--- a/src/pages/status.jsx
+++ b/src/pages/status.jsx
@@ -12,10 +12,10 @@ import {
useRef,
useState,
} from 'preact/hooks';
+import punycode from 'punycode';
import { useHotkeys } from 'react-hotkeys-hook';
import { InView } from 'react-intersection-observer';
import { matchPath, useSearchParams } from 'react-router-dom';
-import { useDebouncedCallback } from 'use-debounce';
import { useSnapshot } from 'valtio';
import Avatar from '../components/avatar';
@@ -1208,7 +1208,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
{postInstance ? (
<>
{' '}
- ({postInstance})
+ ({punycode.toUnicode(postInstance)})
>
) : (
''
diff --git a/src/pages/trending.jsx b/src/pages/trending.jsx
index 8c04359a..bd76192d 100644
--- a/src/pages/trending.jsx
+++ b/src/pages/trending.jsx
@@ -3,6 +3,7 @@ import '../components/links-bar.css';
import { MenuItem } from '@szhsin/react-menu';
import { getBlurHashAverageColor } from 'fast-blurhash';
import { useMemo, useRef, useState } from 'preact/hooks';
+import punycode from 'punycode';
import { useNavigate, useParams } from 'react-router-dom';
import { useSnapshot } from 'valtio';
@@ -161,9 +162,9 @@ function Trending({ columnMode, ...props }) {
url,
width,
} = link;
- const domain = new URL(url).hostname
- .replace(/^www\./, '')
- .replace(/\/$/, '');
+ const domain = punycode.toUnicode(
+ new URL(url).hostname.replace(/^www\./, '').replace(/\/$/, ''),
+ );
let accentColor;
if (blurhash) {
const averageColor = getBlurHashAverageColor(blurhash);