fix(editor): improve affine-link toolbar (#11159)

Closes: [BS-2884](https://linear.app/affine-design/issue/BS-2884/[ui]-hover-邮箱的-toolbar)
This commit is contained in:
fundon
2025-03-25 07:58:40 +00:00
parent 4d15c32242
commit 583bbf3463
3 changed files with 59 additions and 3 deletions

View File

@@ -148,10 +148,11 @@ export function isUrlInClipboard(clipboardData: DataTransfer) {
return isValidUrl(url);
}
export function getHostName(url: string) {
export function getHostName(link: string) {
try {
return new URL(url).hostname;
const url = new URL(link);
return url.hostname || url.pathname;
} catch {
return url;
return link;
}
}