Skip to content

Commit

Permalink
fix: toPunycodeURL if no / specified at the end, do not display pt 2
Browse files Browse the repository at this point in the history
  • Loading branch information
digiwand committed Dec 18, 2024
1 parent 02c065d commit 4d6948e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ui/pages/confirmations/utils/confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ export const isValidASCIIURL = (urlString?: string) => {

export const toPunycodeURL = (urlString: string) => {
try {
return new URL(urlString).href;
const url = new URL(urlString);
const { protocol, hostname, port, search, hash } = url;
const pathname =
url.pathname === '/' && !urlString.endsWith('/') ? '' : url.pathname;

return `${protocol}//${hostname}${port}${pathname}${search}${hash}`;
} catch (err: unknown) {
console.error(`Failed to convert URL to Punycode: ${err}`);
return undefined;
Expand Down

0 comments on commit 4d6948e

Please sign in to comment.