Skip to content

Commit ad245df

Browse files
minor fix of getFavicon (#46)
* Update README.md fix link * minor fix --------- Co-authored-by: Mathieu Dutour <mathieu@dutour.me>
1 parent 8d29873 commit ad245df

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/icon/favicon.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ export function getFavicon(
3434
mask?: Image.Mask;
3535
},
3636
): Image.ImageLike {
37+
// a func adding https:// to the URL
38+
// for cases where the URL is not a full URL
39+
// e.g. "raycast.com"
40+
const withHttps = (url: string) => {
41+
if (!url.startsWith("http")) {
42+
return `https://${url}`;
43+
}
44+
return url;
45+
};
46+
3747
try {
3848
const sanitize = (url: string) => {
3949
if (!url.startsWith("http")) {

tests/src/favicon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default function Command() {
55
return (
66
<List>
77
<List.Item icon={getFavicon("https://raycast.com")} title="Raycast Website" />
8+
<List.Item icon={getFavicon("raycast.com")} title="Raycast Website" />
89
</List>
910
);
1011
}

0 commit comments

Comments
 (0)