Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Added converter for Punycode domains

Steven Tey6e9cbc14dd98
diff --git a/components/app/links/link-card.tsx b/components/app/links/link-card.tsx
index d6e6637776..5687727368 100644
--- a/components/app/links/link-card.tsx
+++ b/components/app/links/link-card.tsx
@@ -30,6 +30,7 @@ import {
import useIntersectionObserver from "@/lib/hooks/use-intersection-observer";
import useDomains from "@/lib/swr/use-domains";
import { CopyPlus, Edit3 } from "lucide-react";
+import punycode from "punycode/";
export default function LinkCard({ props }: { props: LinkProps }) {
const { key, domain, url, createdAt, archived, expiresAt } = props;
@@ -136,7 +137,7 @@ export default function LinkCard({ props }: { props: LinkProps }) {
<div className="w-24 -translate-x-2 cursor-not-allowed truncate text-sm font-semibold text-gray-400 line-through sm:w-full sm:text-base">
{linkConstructor({
key,
- domain,
+ domain: punycode.toUnicode(domain),
pretty: true,
})}
</div>
@@ -150,7 +151,7 @@ export default function LinkCard({ props }: { props: LinkProps }) {
>
{linkConstructor({
key,
- domain,
+ domain: punycode.toUnicode(domain),
pretty: true,
})}
</a>
diff --git a/components/app/links/link-filters.tsx b/components/app/links/link-filters.tsx
index e6404bf253..af18932c89 100644
--- a/components/app/links/link-filters.tsx
+++ b/components/app/links/link-filters.tsx
@@ -10,6 +10,7 @@ import Link from "next/link";
import useLinks from "@/lib/swr/use-links";
import { LoadingSpinner } from "@/components/shared/icons";
import useLinksCount from "@/lib/swr/use-links-count";
+import punycode from "punycode/";
export default function LinkFilters() {
const { primaryDomain } = useDomains();
@@ -141,7 +142,7 @@ const FilterGroup = ({
htmlFor={value}
className="flex w-full cursor-pointer justify-between px-3 py-2 pl-0 text-sm font-medium text-gray-700"
>
- <p>{value}</p>
+ <p>{punycode.toUnicode(value)}</p>
<p className="text-gray-500">{nFormatter(count)}</p>
</label>
</div>
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index 393a998a51..a87a1c9d42 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -40,6 +40,7 @@ import { DEFAULT_LINK_PROPS } from "@/lib/constants";
import useDomains from "@/lib/swr/use-domains";
import { toast } from "react-hot-toast";
import va from "@vercel/analytics";
+import punycode from "punycode/";
function AddEditLinkModal({
showAddEditLinkModal,
@@ -261,7 +262,7 @@ function AddEditLinkModal({
{props
? `Edit ${linkConstructor({
key: props.key,
- domain: props.domain,
+ domain: punycode.toUnicode(props.domain),
pretty: true,
})}`
: "Create a new link"}
@@ -428,7 +429,7 @@ function AddEditLinkModal({
>
{domains?.map(({ slug }) => (
<option key={slug} value={slug}>
- {slug}
+ {punycode.toUnicode(slug)}
</option>
))}
</select>
diff --git a/package.json b/package.json
index 257d97f7fd..6180d01091 100644
--- a/package.json
+++ b/package.json
@@ -54,6 +54,7 @@
"nodemailer": "^6.8.0",
"npm": "^9.1.2",
"prisma": "^4.6.1",
+ "punycode": "^2.3.0",
"react": "^18.2.0",
"react-colorful": "^5.6.1",
"react-dom": "18.2.0",
diff --git a/yarn.lock b/yarn.lock
index 2af3b880d5..d734092787 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5631,6 +5631,11 @@ pseudomap@^1.0.2:
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==
+punycode@^2.3.0:
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"
+ integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==
+
pvtsutils@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.3.2.tgz#9f8570d132cdd3c27ab7d51a2799239bf8d8d5de"