Skip to content

Commit

Permalink
Fix /favicon.ico issue (#26)
Browse files Browse the repository at this point in the history
* Try favicon.ico and fallback to emoji
* Update version
  • Loading branch information
Ben Pevsner committed Jul 30, 2018
1 parent be2144b commit 5e73683
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Favioli",
"description": "Emoji favicons for the web",
"version": "0.3.1",
"version": "0.3.2",
"background": {
"scripts": [ "build/background.js" ]
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "favioli",
"version": "0.3.0",
"version": "0.3.2",
"author": "Ben Pevsner",
"license": "Unlicense",
"description": "Emoji Favicons for the web",
Expand Down
17 changes: 12 additions & 5 deletions source/utilities/faviconHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ export function appendFaviconLink(name) {
if (existingFavicon) {
existingFavicon.setAttribute("href", href);
} else {
const link = createLink(href, EMOJI_SIZE);
const link = createLink(href, EMOJI_SIZE, "image/png");
const defaultLink = createLink("/favicon.ico");
existingFavicon = documentHead.appendChild(link);
documentHead.appendChild(defaultLink);
}
}

Expand Down Expand Up @@ -74,15 +76,20 @@ function createEmojiUrl(emoji) {
/**
* Given a url, create a favicon link
* @param {string} href
* @param {number} size
* @param {number=} size
* @param {string=} type
* @returns {HTMLLinkElement}
*/
function createLink(href, size) {
function createLink(href, size, type) {
const link = document.createElement("link");
link.rel = "icon";
link.type = "image/png";
link.href = href;
link.setAttribute("sizes", `${size}x${size}`);
if (type) {
link.type = type;
}
if (size) {
link.setAttribute("sizes", `${size}x${size}`);
}
return link;
}

Expand Down

0 comments on commit 5e73683

Please sign in to comment.