Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show parts of new URL instead incoming values #4619

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/frontend/src/components/message/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function LabeledLinkConfirmationDialog(
const openLinkSafely = useOpenLinkSafely()
const [isChecked, setIsChecked] = useState(false)
const toggleIsChecked = () => setIsChecked(checked => !checked)

const url = new URL(props.target)
return (
<Dialog onClose={props.onClose}>
<DialogBody>
Expand All @@ -119,7 +119,7 @@ function LabeledLinkConfirmationDialog(
maxHeight: '50vh',
}}
>
{props.realUrl}
{url.href}
</p>
<div style={{ display: 'flex' }}>
<DeltaCheckbox checked={isChecked} onClick={toggleIsChecked} />
Expand All @@ -128,7 +128,7 @@ function LabeledLinkConfirmationDialog(
tx('open_external_url_trust_domain', '$$hostname$$'),
'$$hostname$$',
() => (
<i>{props.hostName}</i>
<i>{url.hostname}</i>
)
)}
</div>
Expand All @@ -144,7 +144,7 @@ function LabeledLinkConfirmationDialog(
.then(() => props.onClose())
}}
>
{tx('copy')}
{tx('global_menu_edit_copy_desktop')}
</FooterActionButton>
<FooterActionButton onClick={props.onClose}>
{tx('cancel')}
Expand Down Expand Up @@ -181,6 +181,7 @@ export const Link = ({
const processQr = useProcessQr()
const asciiUrl = punycode ? punycode.punycode_encoded_url : target

const constructedUrl = new URL(target)
const onClick = (ev: any) => {
ev.preventDefault()
ev.stopPropagation()
Expand All @@ -196,6 +197,15 @@ export const Link = ({
asciiHostname: punycode.ascii_hostname,
asciiUrl: punycode.punycode_encoded_url,
})
} else if (
destination.hostname?.toLowerCase() !==
constructedUrl.hostname.toLowerCase()
) {
openDialog(PunycodeUrlConfirmationDialog, {
originalHostname: destination.hostname ?? '',
asciiHostname: constructedUrl.hostname,
asciiUrl: constructedUrl.href,
})
} else {
openLinkSafely(accountId, target)
}
Expand Down
Loading