@realfavicongenerator/check-favicon 0.4.18 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -17,70 +17,71 @@ export declare enum MessageId {
17
17
  noIcoFavicon = 10,
18
18
  multipleIcoFavicons = 11,
19
19
  icoFaviconDeclared = 12,
20
- noIcoFaviconHref = 13,
21
- icoFavicon404 = 14,
22
- icoFaviconCannotGet = 15,
23
- icoFaviconDownloadable = 16,
24
- icoFaviconExtraSizes = 17,
25
- icoFaviconMissingSizes = 18,
26
- icoFaviconExpectedSizes = 19,
27
- noDesktopPngFavicon = 20,
28
- no96x96DesktopPngFavicon = 21,
29
- desktopPngFaviconDeclared = 22,
30
- noDesktopPngFaviconHref = 23,
31
- desktopPngFaviconCannotGet = 24,
32
- desktopPngFaviconDownloadable = 25,
33
- desktopPngFavicon404 = 26,
34
- desktopPngFaviconWrongSize = 27,
35
- desktopPngFaviconRightSize = 28,
36
- noTouchWebAppTitle = 29,
37
- multipleTouchWebAppTitles = 30,
38
- emptyTouchWebAppTitle = 31,
39
- touchWebAppTitleDeclared = 32,
40
- noTouchIcon = 33,
41
- duplicatedTouchIconSizes = 34,
42
- touchIconWithSize = 35,
43
- touchIconDeclared = 36,
44
- noTouchIconHref = 37,
45
- touchIcon404 = 38,
46
- touchIconCannotGet = 39,
47
- touchIconDownloadable = 40,
48
- touchIconSquare = 41,
49
- touchIcon180x180 = 42,
50
- touchIconNotSquare = 43,
51
- touchIconWrongSize = 44,
52
- noManifest = 45,
53
- noManifestHref = 46,
54
- manifest404 = 47,
55
- manifestCannotGet = 48,
56
- manifestInvalidJson = 49,
57
- manifestName = 50,
58
- noManifestName = 51,
59
- manifestShortName = 52,
60
- noManifestShortName = 53,
61
- manifestBackgroundColor = 54,
62
- noManifestBackgroundColor = 55,
63
- manifestThemeColor = 56,
64
- noManifestThemeColor = 57,
65
- noManifestIcons = 58,
66
- noManifestIcon = 59,
67
- manifestIconDeclared = 60,
68
- manifestIconCannotGet = 61,
69
- manifestIconDownloadable = 62,
70
- manifestIcon404 = 63,
71
- manifestIconNoHref = 64,
72
- manifestIconNotSquare = 65,
73
- manifestIconRightSize = 66,
74
- manifestIconSquare = 67,
75
- manifestIconWrongSize = 68,
76
- googleNoRobotsFile = 69,
77
- googleRobotsFileFound = 70,
78
- googleIcoBlockedByRobots = 71,
79
- googleIcoAllowedByRobots = 72,
80
- googleSvgIconBlockedByRobots = 73,
81
- googleSvgIconAllowedByRobots = 74,
82
- googlePngIconBlockedByRobots = 75,
83
- googlePngIconAllowedByRobots = 76
20
+ icoFaviconImplicitInRoot = 13,
21
+ noIcoFaviconHref = 14,
22
+ icoFavicon404 = 15,
23
+ icoFaviconCannotGet = 16,
24
+ icoFaviconDownloadable = 17,
25
+ icoFaviconExtraSizes = 18,
26
+ icoFaviconMissingSizes = 19,
27
+ icoFaviconExpectedSizes = 20,
28
+ noDesktopPngFavicon = 21,
29
+ no96x96DesktopPngFavicon = 22,
30
+ desktopPngFaviconDeclared = 23,
31
+ noDesktopPngFaviconHref = 24,
32
+ desktopPngFaviconCannotGet = 25,
33
+ desktopPngFaviconDownloadable = 26,
34
+ desktopPngFavicon404 = 27,
35
+ desktopPngFaviconWrongSize = 28,
36
+ desktopPngFaviconRightSize = 29,
37
+ noTouchWebAppTitle = 30,
38
+ multipleTouchWebAppTitles = 31,
39
+ emptyTouchWebAppTitle = 32,
40
+ touchWebAppTitleDeclared = 33,
41
+ noTouchIcon = 34,
42
+ duplicatedTouchIconSizes = 35,
43
+ touchIconWithSize = 36,
44
+ touchIconDeclared = 37,
45
+ noTouchIconHref = 38,
46
+ touchIcon404 = 39,
47
+ touchIconCannotGet = 40,
48
+ touchIconDownloadable = 41,
49
+ touchIconSquare = 42,
50
+ touchIcon180x180 = 43,
51
+ touchIconNotSquare = 44,
52
+ touchIconWrongSize = 45,
53
+ noManifest = 46,
54
+ noManifestHref = 47,
55
+ manifest404 = 48,
56
+ manifestCannotGet = 49,
57
+ manifestInvalidJson = 50,
58
+ manifestName = 51,
59
+ noManifestName = 52,
60
+ manifestShortName = 53,
61
+ noManifestShortName = 54,
62
+ manifestBackgroundColor = 55,
63
+ noManifestBackgroundColor = 56,
64
+ manifestThemeColor = 57,
65
+ noManifestThemeColor = 58,
66
+ noManifestIcons = 59,
67
+ noManifestIcon = 60,
68
+ manifestIconDeclared = 61,
69
+ manifestIconCannotGet = 62,
70
+ manifestIconDownloadable = 63,
71
+ manifestIcon404 = 64,
72
+ manifestIconNoHref = 65,
73
+ manifestIconNotSquare = 66,
74
+ manifestIconRightSize = 67,
75
+ manifestIconSquare = 68,
76
+ manifestIconWrongSize = 69,
77
+ googleNoRobotsFile = 70,
78
+ googleRobotsFileFound = 71,
79
+ googleIcoBlockedByRobots = 72,
80
+ googleIcoAllowedByRobots = 73,
81
+ googleSvgIconBlockedByRobots = 74,
82
+ googleSvgIconAllowedByRobots = 75,
83
+ googlePngIconBlockedByRobots = 76,
84
+ googlePngIconAllowedByRobots = 77
84
85
  }
85
86
  export type CheckerMessage = {
86
87
  status: CheckerStatus;
@@ -118,7 +119,7 @@ export type TouchIconTitleReport = {
118
119
  };
119
120
  export type TouchIconIconReport = {
120
121
  messages: CheckerMessage[];
121
- touchIcon: string | null;
122
+ icon: CheckedIcon | null;
122
123
  };
123
124
  export type WebAppManifestReport = {
124
125
  messages: CheckerMessage[];
@@ -126,7 +127,7 @@ export type WebAppManifestReport = {
126
127
  shortName?: string;
127
128
  backgroundColor?: string;
128
129
  themeColor?: string;
129
- icon: string | null;
130
+ icon: CheckedIcon | null;
130
131
  };
131
132
  export type FaviconReport = {
132
133
  desktop: DesktopFaviconReport;
package/dist/types.js CHANGED
@@ -22,68 +22,69 @@ var MessageId;
22
22
  MessageId[MessageId["noIcoFavicon"] = 10] = "noIcoFavicon";
23
23
  MessageId[MessageId["multipleIcoFavicons"] = 11] = "multipleIcoFavicons";
24
24
  MessageId[MessageId["icoFaviconDeclared"] = 12] = "icoFaviconDeclared";
25
- MessageId[MessageId["noIcoFaviconHref"] = 13] = "noIcoFaviconHref";
26
- MessageId[MessageId["icoFavicon404"] = 14] = "icoFavicon404";
27
- MessageId[MessageId["icoFaviconCannotGet"] = 15] = "icoFaviconCannotGet";
28
- MessageId[MessageId["icoFaviconDownloadable"] = 16] = "icoFaviconDownloadable";
29
- MessageId[MessageId["icoFaviconExtraSizes"] = 17] = "icoFaviconExtraSizes";
30
- MessageId[MessageId["icoFaviconMissingSizes"] = 18] = "icoFaviconMissingSizes";
31
- MessageId[MessageId["icoFaviconExpectedSizes"] = 19] = "icoFaviconExpectedSizes";
32
- MessageId[MessageId["noDesktopPngFavicon"] = 20] = "noDesktopPngFavicon";
33
- MessageId[MessageId["no96x96DesktopPngFavicon"] = 21] = "no96x96DesktopPngFavicon";
34
- MessageId[MessageId["desktopPngFaviconDeclared"] = 22] = "desktopPngFaviconDeclared";
35
- MessageId[MessageId["noDesktopPngFaviconHref"] = 23] = "noDesktopPngFaviconHref";
36
- MessageId[MessageId["desktopPngFaviconCannotGet"] = 24] = "desktopPngFaviconCannotGet";
37
- MessageId[MessageId["desktopPngFaviconDownloadable"] = 25] = "desktopPngFaviconDownloadable";
38
- MessageId[MessageId["desktopPngFavicon404"] = 26] = "desktopPngFavicon404";
39
- MessageId[MessageId["desktopPngFaviconWrongSize"] = 27] = "desktopPngFaviconWrongSize";
40
- MessageId[MessageId["desktopPngFaviconRightSize"] = 28] = "desktopPngFaviconRightSize";
41
- MessageId[MessageId["noTouchWebAppTitle"] = 29] = "noTouchWebAppTitle";
42
- MessageId[MessageId["multipleTouchWebAppTitles"] = 30] = "multipleTouchWebAppTitles";
43
- MessageId[MessageId["emptyTouchWebAppTitle"] = 31] = "emptyTouchWebAppTitle";
44
- MessageId[MessageId["touchWebAppTitleDeclared"] = 32] = "touchWebAppTitleDeclared";
45
- MessageId[MessageId["noTouchIcon"] = 33] = "noTouchIcon";
46
- MessageId[MessageId["duplicatedTouchIconSizes"] = 34] = "duplicatedTouchIconSizes";
47
- MessageId[MessageId["touchIconWithSize"] = 35] = "touchIconWithSize";
48
- MessageId[MessageId["touchIconDeclared"] = 36] = "touchIconDeclared";
49
- MessageId[MessageId["noTouchIconHref"] = 37] = "noTouchIconHref";
50
- MessageId[MessageId["touchIcon404"] = 38] = "touchIcon404";
51
- MessageId[MessageId["touchIconCannotGet"] = 39] = "touchIconCannotGet";
52
- MessageId[MessageId["touchIconDownloadable"] = 40] = "touchIconDownloadable";
53
- MessageId[MessageId["touchIconSquare"] = 41] = "touchIconSquare";
54
- MessageId[MessageId["touchIcon180x180"] = 42] = "touchIcon180x180";
55
- MessageId[MessageId["touchIconNotSquare"] = 43] = "touchIconNotSquare";
56
- MessageId[MessageId["touchIconWrongSize"] = 44] = "touchIconWrongSize";
57
- MessageId[MessageId["noManifest"] = 45] = "noManifest";
58
- MessageId[MessageId["noManifestHref"] = 46] = "noManifestHref";
59
- MessageId[MessageId["manifest404"] = 47] = "manifest404";
60
- MessageId[MessageId["manifestCannotGet"] = 48] = "manifestCannotGet";
61
- MessageId[MessageId["manifestInvalidJson"] = 49] = "manifestInvalidJson";
62
- MessageId[MessageId["manifestName"] = 50] = "manifestName";
63
- MessageId[MessageId["noManifestName"] = 51] = "noManifestName";
64
- MessageId[MessageId["manifestShortName"] = 52] = "manifestShortName";
65
- MessageId[MessageId["noManifestShortName"] = 53] = "noManifestShortName";
66
- MessageId[MessageId["manifestBackgroundColor"] = 54] = "manifestBackgroundColor";
67
- MessageId[MessageId["noManifestBackgroundColor"] = 55] = "noManifestBackgroundColor";
68
- MessageId[MessageId["manifestThemeColor"] = 56] = "manifestThemeColor";
69
- MessageId[MessageId["noManifestThemeColor"] = 57] = "noManifestThemeColor";
70
- MessageId[MessageId["noManifestIcons"] = 58] = "noManifestIcons";
71
- MessageId[MessageId["noManifestIcon"] = 59] = "noManifestIcon";
72
- MessageId[MessageId["manifestIconDeclared"] = 60] = "manifestIconDeclared";
73
- MessageId[MessageId["manifestIconCannotGet"] = 61] = "manifestIconCannotGet";
74
- MessageId[MessageId["manifestIconDownloadable"] = 62] = "manifestIconDownloadable";
75
- MessageId[MessageId["manifestIcon404"] = 63] = "manifestIcon404";
76
- MessageId[MessageId["manifestIconNoHref"] = 64] = "manifestIconNoHref";
77
- MessageId[MessageId["manifestIconNotSquare"] = 65] = "manifestIconNotSquare";
78
- MessageId[MessageId["manifestIconRightSize"] = 66] = "manifestIconRightSize";
79
- MessageId[MessageId["manifestIconSquare"] = 67] = "manifestIconSquare";
80
- MessageId[MessageId["manifestIconWrongSize"] = 68] = "manifestIconWrongSize";
81
- MessageId[MessageId["googleNoRobotsFile"] = 69] = "googleNoRobotsFile";
82
- MessageId[MessageId["googleRobotsFileFound"] = 70] = "googleRobotsFileFound";
83
- MessageId[MessageId["googleIcoBlockedByRobots"] = 71] = "googleIcoBlockedByRobots";
84
- MessageId[MessageId["googleIcoAllowedByRobots"] = 72] = "googleIcoAllowedByRobots";
85
- MessageId[MessageId["googleSvgIconBlockedByRobots"] = 73] = "googleSvgIconBlockedByRobots";
86
- MessageId[MessageId["googleSvgIconAllowedByRobots"] = 74] = "googleSvgIconAllowedByRobots";
87
- MessageId[MessageId["googlePngIconBlockedByRobots"] = 75] = "googlePngIconBlockedByRobots";
88
- MessageId[MessageId["googlePngIconAllowedByRobots"] = 76] = "googlePngIconAllowedByRobots";
25
+ MessageId[MessageId["icoFaviconImplicitInRoot"] = 13] = "icoFaviconImplicitInRoot";
26
+ MessageId[MessageId["noIcoFaviconHref"] = 14] = "noIcoFaviconHref";
27
+ MessageId[MessageId["icoFavicon404"] = 15] = "icoFavicon404";
28
+ MessageId[MessageId["icoFaviconCannotGet"] = 16] = "icoFaviconCannotGet";
29
+ MessageId[MessageId["icoFaviconDownloadable"] = 17] = "icoFaviconDownloadable";
30
+ MessageId[MessageId["icoFaviconExtraSizes"] = 18] = "icoFaviconExtraSizes";
31
+ MessageId[MessageId["icoFaviconMissingSizes"] = 19] = "icoFaviconMissingSizes";
32
+ MessageId[MessageId["icoFaviconExpectedSizes"] = 20] = "icoFaviconExpectedSizes";
33
+ MessageId[MessageId["noDesktopPngFavicon"] = 21] = "noDesktopPngFavicon";
34
+ MessageId[MessageId["no96x96DesktopPngFavicon"] = 22] = "no96x96DesktopPngFavicon";
35
+ MessageId[MessageId["desktopPngFaviconDeclared"] = 23] = "desktopPngFaviconDeclared";
36
+ MessageId[MessageId["noDesktopPngFaviconHref"] = 24] = "noDesktopPngFaviconHref";
37
+ MessageId[MessageId["desktopPngFaviconCannotGet"] = 25] = "desktopPngFaviconCannotGet";
38
+ MessageId[MessageId["desktopPngFaviconDownloadable"] = 26] = "desktopPngFaviconDownloadable";
39
+ MessageId[MessageId["desktopPngFavicon404"] = 27] = "desktopPngFavicon404";
40
+ MessageId[MessageId["desktopPngFaviconWrongSize"] = 28] = "desktopPngFaviconWrongSize";
41
+ MessageId[MessageId["desktopPngFaviconRightSize"] = 29] = "desktopPngFaviconRightSize";
42
+ MessageId[MessageId["noTouchWebAppTitle"] = 30] = "noTouchWebAppTitle";
43
+ MessageId[MessageId["multipleTouchWebAppTitles"] = 31] = "multipleTouchWebAppTitles";
44
+ MessageId[MessageId["emptyTouchWebAppTitle"] = 32] = "emptyTouchWebAppTitle";
45
+ MessageId[MessageId["touchWebAppTitleDeclared"] = 33] = "touchWebAppTitleDeclared";
46
+ MessageId[MessageId["noTouchIcon"] = 34] = "noTouchIcon";
47
+ MessageId[MessageId["duplicatedTouchIconSizes"] = 35] = "duplicatedTouchIconSizes";
48
+ MessageId[MessageId["touchIconWithSize"] = 36] = "touchIconWithSize";
49
+ MessageId[MessageId["touchIconDeclared"] = 37] = "touchIconDeclared";
50
+ MessageId[MessageId["noTouchIconHref"] = 38] = "noTouchIconHref";
51
+ MessageId[MessageId["touchIcon404"] = 39] = "touchIcon404";
52
+ MessageId[MessageId["touchIconCannotGet"] = 40] = "touchIconCannotGet";
53
+ MessageId[MessageId["touchIconDownloadable"] = 41] = "touchIconDownloadable";
54
+ MessageId[MessageId["touchIconSquare"] = 42] = "touchIconSquare";
55
+ MessageId[MessageId["touchIcon180x180"] = 43] = "touchIcon180x180";
56
+ MessageId[MessageId["touchIconNotSquare"] = 44] = "touchIconNotSquare";
57
+ MessageId[MessageId["touchIconWrongSize"] = 45] = "touchIconWrongSize";
58
+ MessageId[MessageId["noManifest"] = 46] = "noManifest";
59
+ MessageId[MessageId["noManifestHref"] = 47] = "noManifestHref";
60
+ MessageId[MessageId["manifest404"] = 48] = "manifest404";
61
+ MessageId[MessageId["manifestCannotGet"] = 49] = "manifestCannotGet";
62
+ MessageId[MessageId["manifestInvalidJson"] = 50] = "manifestInvalidJson";
63
+ MessageId[MessageId["manifestName"] = 51] = "manifestName";
64
+ MessageId[MessageId["noManifestName"] = 52] = "noManifestName";
65
+ MessageId[MessageId["manifestShortName"] = 53] = "manifestShortName";
66
+ MessageId[MessageId["noManifestShortName"] = 54] = "noManifestShortName";
67
+ MessageId[MessageId["manifestBackgroundColor"] = 55] = "manifestBackgroundColor";
68
+ MessageId[MessageId["noManifestBackgroundColor"] = 56] = "noManifestBackgroundColor";
69
+ MessageId[MessageId["manifestThemeColor"] = 57] = "manifestThemeColor";
70
+ MessageId[MessageId["noManifestThemeColor"] = 58] = "noManifestThemeColor";
71
+ MessageId[MessageId["noManifestIcons"] = 59] = "noManifestIcons";
72
+ MessageId[MessageId["noManifestIcon"] = 60] = "noManifestIcon";
73
+ MessageId[MessageId["manifestIconDeclared"] = 61] = "manifestIconDeclared";
74
+ MessageId[MessageId["manifestIconCannotGet"] = 62] = "manifestIconCannotGet";
75
+ MessageId[MessageId["manifestIconDownloadable"] = 63] = "manifestIconDownloadable";
76
+ MessageId[MessageId["manifestIcon404"] = 64] = "manifestIcon404";
77
+ MessageId[MessageId["manifestIconNoHref"] = 65] = "manifestIconNoHref";
78
+ MessageId[MessageId["manifestIconNotSquare"] = 66] = "manifestIconNotSquare";
79
+ MessageId[MessageId["manifestIconRightSize"] = 67] = "manifestIconRightSize";
80
+ MessageId[MessageId["manifestIconSquare"] = 68] = "manifestIconSquare";
81
+ MessageId[MessageId["manifestIconWrongSize"] = 69] = "manifestIconWrongSize";
82
+ MessageId[MessageId["googleNoRobotsFile"] = 70] = "googleNoRobotsFile";
83
+ MessageId[MessageId["googleRobotsFileFound"] = 71] = "googleRobotsFileFound";
84
+ MessageId[MessageId["googleIcoBlockedByRobots"] = 72] = "googleIcoBlockedByRobots";
85
+ MessageId[MessageId["googleIcoAllowedByRobots"] = 73] = "googleIcoAllowedByRobots";
86
+ MessageId[MessageId["googleSvgIconBlockedByRobots"] = 74] = "googleSvgIconBlockedByRobots";
87
+ MessageId[MessageId["googleSvgIconAllowedByRobots"] = 75] = "googleSvgIconAllowedByRobots";
88
+ MessageId[MessageId["googlePngIconBlockedByRobots"] = 76] = "googlePngIconBlockedByRobots";
89
+ MessageId[MessageId["googlePngIconAllowedByRobots"] = 77] = "googlePngIconAllowedByRobots";
89
90
  })(MessageId || (exports.MessageId = MessageId = {}));
@@ -257,6 +257,6 @@ const checkWebAppManifestFile = (manifest, baseUrl, fetcher) => __awaiter(void 0
257
257
  }
258
258
  finally { if (e_1) throw e_1.error; }
259
259
  }
260
- return { messages, name, shortName, backgroundColor, themeColor, icon: icon ? icon.content : null };
260
+ return { messages, name, shortName, backgroundColor, themeColor, icon };
261
261
  });
262
262
  exports.checkWebAppManifestFile = checkWebAppManifestFile;
@@ -167,6 +167,11 @@ test('checkWebAppManifestFile - Everything is fine', () => __awaiter(void 0, voi
167
167
  shortName: 'Short!',
168
168
  backgroundColor: '#123456',
169
169
  themeColor: '#abcdef',
170
- icon: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon512)), 'image/png')
170
+ icon: {
171
+ content: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon512)), 'image/png'),
172
+ url: "https://example.com/icon-512.png",
173
+ width: 512,
174
+ height: 512,
175
+ },
171
176
  });
172
177
  }));
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
Binary file
package/jest.config.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realfavicongenerator/check-favicon",
3
- "version": "0.4.18",
3
+ "version": "0.5.2",
4
4
  "description": "Check the favicon of a website",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,5 +40,5 @@
40
40
  "robots-parser": "^3.0.1",
41
41
  "sharp": "^0.32.6"
42
42
  },
43
- "gitHead": "6d09c58437b7cd0c00c61fe38c278e8c28099c0a"
43
+ "gitHead": "25d06206eedd021db005448c6b2cf015f6cfc3cf"
44
44
  }
package/src/check.ts CHANGED
File without changes
File without changes
File without changes
@@ -0,0 +1,280 @@
1
+ import { parse } from 'node-html-parser'
2
+ import { checkIcoFavicon } from "./ico";
3
+ import { CheckerMessage, CheckerStatus, DesktopSingleReport, FetchResponse, MessageId } from '../types';
4
+ import { filePathToReadableStream } from '../helper';
5
+ import { testFetcher } from '../test-helper';
6
+
7
+ type TestOutput = {
8
+ messages: Pick<CheckerMessage, 'id' | 'status'>[];
9
+ icon: DesktopSingleReport['icon'];
10
+ }
11
+
12
+ const runIcoTest = async (
13
+ headFragment: string | null,
14
+ output: TestOutput,
15
+ fetchDatabase: { [url: string]: FetchResponse } = {},
16
+ checkContent = true
17
+ ) => {
18
+ const root = headFragment ? parse(headFragment) : null;
19
+ const result = await checkIcoFavicon('https://example.com/', root, testFetcher(fetchDatabase));
20
+ const filteredMessages = result.messages.map(m => ({ status: m.status, id: m.id }));
21
+ expect(filteredMessages).toEqual(output.messages);
22
+
23
+ // Check icon properties - icon is always returned by checkIcoFavicon
24
+ const resultIcon = result.icon!;
25
+ const outputIcon = output.icon!;
26
+
27
+ expect(resultIcon.url).toEqual(outputIcon.url);
28
+ expect(resultIcon.width).toEqual(outputIcon.width);
29
+ expect(resultIcon.height).toEqual(outputIcon.height);
30
+
31
+ // For content, just check if it's null or not null unless exact match is needed
32
+ if (checkContent && outputIcon.content === null) {
33
+ expect(resultIcon.content).toBeNull();
34
+ } else if (checkContent && outputIcon.content !== null) {
35
+ expect(resultIcon.content).not.toBeNull();
36
+ expect(resultIcon.content).toMatch(/^data:image\/(png|bmp);base64,/);
37
+ }
38
+ }
39
+
40
+ test('checkIcoFavicon - noHead', async () => {
41
+ await runIcoTest(null, {
42
+ messages: [{
43
+ status: CheckerStatus.Error,
44
+ id: MessageId.noHead,
45
+ }],
46
+ icon: {
47
+ content: null,
48
+ url: null,
49
+ width: null,
50
+ height: null,
51
+ }
52
+ });
53
+ })
54
+
55
+ test('checkIcoFavicon - noIcoFavicon', async () => {
56
+ await runIcoTest(`<title>Some text</title>`, {
57
+ messages: [{
58
+ status: CheckerStatus.Error,
59
+ id: MessageId.noIcoFavicon,
60
+ }],
61
+ icon: {
62
+ content: null,
63
+ url: null,
64
+ width: null,
65
+ height: null,
66
+ }
67
+ });
68
+ })
69
+
70
+ test('checkIcoFavicon - implicit /favicon.ico when not declared', async () => {
71
+ const testIconPath = './fixtures/simple-ico.ico';
72
+
73
+ await runIcoTest(`<title>Some text</title>`, {
74
+ messages: [{
75
+ status: CheckerStatus.Ok,
76
+ id: MessageId.icoFaviconImplicitInRoot,
77
+ },{
78
+ status: CheckerStatus.Ok,
79
+ id: MessageId.icoFaviconDownloadable,
80
+ }, {
81
+ status: CheckerStatus.Ok,
82
+ id: MessageId.icoFaviconExpectedSizes,
83
+ }],
84
+ icon: {
85
+ content: "data:image/png;base64,placeholder", // Will be checked for format only
86
+ url: 'https://example.com/favicon.ico',
87
+ width: 48,
88
+ height: 48,
89
+ }
90
+ }, {
91
+ 'https://example.com/favicon.ico': {
92
+ status: 200,
93
+ contentType: 'image/x-icon',
94
+ readableStream: await filePathToReadableStream(testIconPath)
95
+ }
96
+ });
97
+ })
98
+
99
+ test('checkIcoFavicon - multipleIcoFavicons with shortcut icon', async () => {
100
+ await runIcoTest(`
101
+ <link rel="shortcut icon" href="/favicon1.ico" />
102
+ <link rel="shortcut icon" href="/favicon2.ico" />
103
+ `, {
104
+ messages: [{
105
+ status: CheckerStatus.Error,
106
+ id: MessageId.multipleIcoFavicons,
107
+ }],
108
+ icon: {
109
+ content: null,
110
+ url: null,
111
+ width: null,
112
+ height: null,
113
+ }
114
+ });
115
+ })
116
+
117
+ test('checkIcoFavicon - multipleIcoFavicons with type="image/x-icon"', async () => {
118
+ await runIcoTest(`
119
+ <link rel="icon" type="image/x-icon" href="/favicon1.ico" />
120
+ <link rel="icon" type="image/x-icon" href="/favicon2.ico" />
121
+ `, {
122
+ messages: [{
123
+ status: CheckerStatus.Error,
124
+ id: MessageId.multipleIcoFavicons,
125
+ }],
126
+ icon: {
127
+ content: null,
128
+ url: null,
129
+ width: null,
130
+ height: null,
131
+ }
132
+ });
133
+ })
134
+
135
+ test('checkIcoFavicon - icoFaviconDeclared & noIcoFaviconHref', async () => {
136
+ await runIcoTest(`<link rel="shortcut icon" />`, {
137
+ messages: [{
138
+ status: CheckerStatus.Ok,
139
+ id: MessageId.icoFaviconDeclared,
140
+ }, {
141
+ status: CheckerStatus.Error,
142
+ id: MessageId.noIcoFaviconHref,
143
+ }],
144
+ icon: {
145
+ content: null,
146
+ url: null,
147
+ width: null,
148
+ height: null,
149
+ }
150
+ });
151
+ })
152
+
153
+ test('checkIcoFavicon - icoFaviconDeclared & icoFavicon404', async () => {
154
+ await runIcoTest(`<link rel="shortcut icon" href="/favicon.ico" />`, {
155
+ messages: [{
156
+ status: CheckerStatus.Ok,
157
+ id: MessageId.icoFaviconDeclared,
158
+ }, {
159
+ status: CheckerStatus.Error,
160
+ id: MessageId.icoFavicon404,
161
+ }],
162
+ icon: {
163
+ content: null,
164
+ url: 'https://example.com/favicon.ico',
165
+ width: null,
166
+ height: null,
167
+ }
168
+ });
169
+ })
170
+
171
+ test('checkIcoFavicon - icoFaviconDeclared & icoFaviconCannotGet', async () => {
172
+ await runIcoTest(`<link rel="shortcut icon" href="/favicon.ico" />`, {
173
+ messages: [{
174
+ status: CheckerStatus.Ok,
175
+ id: MessageId.icoFaviconDeclared,
176
+ }, {
177
+ status: CheckerStatus.Error,
178
+ id: MessageId.icoFaviconCannotGet,
179
+ }],
180
+ icon: {
181
+ content: null,
182
+ url: 'https://example.com/favicon.ico',
183
+ width: null,
184
+ height: null,
185
+ }
186
+ }, {
187
+ 'https://example.com/favicon.ico': {
188
+ status: 403,
189
+ contentType: 'image/x-icon'
190
+ }
191
+ });
192
+ })
193
+
194
+ test('checkIcoFavicon - icoFaviconDeclared & icoFaviconDownloadable & icoFaviconExpectedSizes', async () => {
195
+ const testIconPath = './fixtures/simple-ico.ico';
196
+
197
+ await runIcoTest(`<link rel="shortcut icon" href="/favicon.ico" />`, {
198
+ messages: [{
199
+ status: CheckerStatus.Ok,
200
+ id: MessageId.icoFaviconDeclared,
201
+ }, {
202
+ status: CheckerStatus.Ok,
203
+ id: MessageId.icoFaviconDownloadable,
204
+ }, {
205
+ status: CheckerStatus.Ok,
206
+ id: MessageId.icoFaviconExpectedSizes,
207
+ }],
208
+ icon: {
209
+ content: "data:image/png;base64,placeholder", // Will be checked for format only
210
+ url: 'https://example.com/favicon.ico',
211
+ width: 48,
212
+ height: 48,
213
+ }
214
+ }, {
215
+ 'https://example.com/favicon.ico': {
216
+ status: 200,
217
+ contentType: 'image/x-icon',
218
+ readableStream: await filePathToReadableStream(testIconPath)
219
+ }
220
+ });
221
+ })
222
+
223
+ test('checkIcoFavicon - using type="image/x-icon"', async () => {
224
+ const testIconPath = './fixtures/simple-ico.ico';
225
+
226
+ await runIcoTest(`<link rel="icon" type="image/x-icon" href="/favicon.ico" />`, {
227
+ messages: [{
228
+ status: CheckerStatus.Ok,
229
+ id: MessageId.icoFaviconDeclared,
230
+ }, {
231
+ status: CheckerStatus.Ok,
232
+ id: MessageId.icoFaviconDownloadable,
233
+ }, {
234
+ status: CheckerStatus.Ok,
235
+ id: MessageId.icoFaviconExpectedSizes,
236
+ }],
237
+ icon: {
238
+ content: "data:image/png;base64,placeholder", // Will be checked for format only
239
+ url: 'https://example.com/favicon.ico',
240
+ width: 48,
241
+ height: 48,
242
+ }
243
+ }, {
244
+ 'https://example.com/favicon.ico': {
245
+ status: 200,
246
+ contentType: 'image/x-icon',
247
+ readableStream: await filePathToReadableStream(testIconPath)
248
+ }
249
+ });
250
+ })
251
+
252
+ // For https://github.com/RealFaviconGenerator/core/issues/2
253
+ test('checkIcoFavicon - Protocol-relative URL', async () => {
254
+ const testIconPath = './fixtures/simple-ico.ico';
255
+
256
+ await runIcoTest(`<link rel="shortcut icon" href="//example.com/favicon.ico" />`, {
257
+ messages: [{
258
+ status: CheckerStatus.Ok,
259
+ id: MessageId.icoFaviconDeclared,
260
+ }, {
261
+ status: CheckerStatus.Ok,
262
+ id: MessageId.icoFaviconDownloadable,
263
+ }, {
264
+ status: CheckerStatus.Ok,
265
+ id: MessageId.icoFaviconExpectedSizes,
266
+ }],
267
+ icon: {
268
+ content: "data:image/png;base64,placeholder", // Will be checked for format only
269
+ url: 'https://example.com/favicon.ico',
270
+ width: 48,
271
+ height: 48,
272
+ }
273
+ }, {
274
+ 'https://example.com/favicon.ico': {
275
+ status: 200,
276
+ contentType: 'image/x-icon',
277
+ readableStream: await filePathToReadableStream(testIconPath)
278
+ }
279
+ });
280
+ })