Skip to content

Commit

Permalink
Merge pull request xjh22222228#275 from yodhcn/main
Browse files Browse the repository at this point in the history
feat: 从Chrome书签提取icon失败时,利用icon服务直接从url获取icon
  • Loading branch information
xjh22222228 authored May 7, 2024
2 parents c69f5f2 + f053cb0 commit cc99aa4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/utils/bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ function getUrl(node: Element) {
return node.getAttribute('href') || ''
}

function getIconFromUrl(url) {
if (!url) return null;
const hostname = (new URL(url)).hostname;
return hostname && `https://icons.bitwarden.net/${hostname}/icon.png`
}

function getIcon(node: Element) {
return node.getAttribute('icon') || null
return node.getAttribute('icon') || getIconFromUrl(getUrl(node))
}

const nowCratedAt = getCreatedAt()
Expand Down

0 comments on commit cc99aa4

Please sign in to comment.