Skip to content

Commit 3d196e8

Browse files
authored
Merge pull request #708 from LemmyNet/main
[pull] master from LemmyNet:main
2 parents a34a46b + 7437d4c commit 3d196e8

5 files changed

Lines changed: 28 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"history": "^5.3.0",
6868
"html-to-text": "^10.0.0",
6969
"i18next": "^23.14.0",
70+
"idna-uts46-hx": "^6.1.7",
7071
"inferno": "^9.1.0",
7172
"inferno-create-element": "^9.1.0",
7273
"inferno-helmet": "^5.2.1",

pnpm-lock.yaml

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

src/shared/components/app/footer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { GetSiteResponse } from "lemmy-js-client";
44
import { docsUrl, joinLemmyUrl, repoUrl } from "@utils/config";
55
import { I18NextService } from "../../services";
66
import { VERSION } from "../../version";
7+
import { hostname } from "@utils/helpers";
78

89
interface FooterProps {
910
site?: GetSiteResponse;
@@ -54,7 +55,7 @@ export class Footer extends Component<FooterProps, never> {
5455
</li>
5556
<li className="nav-item">
5657
<a className="nav-link" href={joinLemmyUrl}>
57-
{new URL(joinLemmyUrl).hostname}
58+
{hostname(joinLemmyUrl)}
5859
</a>
5960
</li>
6061
</ul>

src/shared/components/post/metadata-card.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Post } from "lemmy-js-client";
33
import sanitize from "sanitize-html";
44
import { relTags } from "@utils/config";
55
import { Icon } from "../common/icon";
6+
import { hostname } from "@utils/helpers";
67

78
interface MetadataCardProps {
89
post: Post;
@@ -31,7 +32,7 @@ export class MetadataCard extends Component<MetadataCardProps> {
3132
href={post.url}
3233
rel={relTags}
3334
>
34-
{new URL(post.url).hostname}
35+
{hostname(post.url)}
3536
<Icon icon="external-link" classes="ms-1" />
3637
</a>
3738
</span>

src/shared/utils/helpers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { RouteComponentProps } from "inferno-router";
22
import { RequestState } from "@services/HttpService";
33
import { PostView } from "lemmy-js-client";
44
import { Action } from "history";
5+
import { toUnicode } from "idna-uts46-hx";
56

67
// Intended to allow reloading all the data of the current page by clicking the
78
// navigation link of the current page.
@@ -133,7 +134,9 @@ export function groupBy<T>(
133134

134135
export function hostname(url: string): string {
135136
const cUrl = new URL(url);
136-
return cUrl.port ? `${cUrl.hostname}:${cUrl.port}` : `${cUrl.hostname}`;
137+
// Necessary to convert international hostnames to their unicode
138+
const hostname: string = toUnicode(cUrl.hostname);
139+
return cUrl.port ? `${hostname}:${cUrl.port}` : `${hostname}`;
137140
}
138141

139142
export function hsl(num: number) {

0 commit comments

Comments
 (0)