@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/README.md +0 -0
- package/dist/desktop/ico.js +73 -43
- package/dist/desktop/ico.test.d.ts +1 -0
- package/dist/desktop/ico.test.js +263 -0
- package/dist/touch-icon.js +7 -7
- package/dist/touch-icon.test.js +23 -5
- package/dist/types.d.ts +67 -66
- package/dist/types.js +65 -64
- package/dist/web-app-manifest.js +1 -1
- package/dist/web-app-manifest.test.js +6 -1
- package/fixtures/16x16.png +0 -0
- package/fixtures/180x180.png +0 -0
- package/fixtures/192x192.png +0 -0
- package/fixtures/32x32.png +0 -0
- package/fixtures/48x48.png +0 -0
- package/fixtures/512x512.png +0 -0
- package/fixtures/96x96.png +0 -0
- package/fixtures/happy-face.svg +0 -0
- package/fixtures/logo-transparent.png +0 -0
- package/fixtures/non-square.png +0 -0
- package/fixtures/simple-ico.ico +0 -0
- package/jest.config.js +0 -0
- package/package.json +2 -2
- package/src/check.ts +0 -0
- package/src/desktop/desktop.test.ts +0 -0
- package/src/desktop/desktop.ts +0 -0
- package/src/desktop/ico.test.ts +280 -0
- package/src/desktop/ico.ts +77 -47
- package/src/google.test.ts +0 -0
- package/src/google.ts +0 -0
- package/src/helper.test.ts +0 -0
- package/src/helper.ts +0 -0
- package/src/index.ts +0 -0
- package/src/test-helper.ts +0 -0
- package/src/touch-icon.test.ts +25 -8
- package/src/touch-icon.ts +7 -7
- package/src/types.ts +3 -2
- package/src/web-app-manifest.test.ts +6 -1
- package/src/web-app-manifest.ts +1 -1
- package/tsconfig.json +0 -0
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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:
|
|
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["
|
|
26
|
-
MessageId[MessageId["
|
|
27
|
-
MessageId[MessageId["
|
|
28
|
-
MessageId[MessageId["
|
|
29
|
-
MessageId[MessageId["
|
|
30
|
-
MessageId[MessageId["
|
|
31
|
-
MessageId[MessageId["
|
|
32
|
-
MessageId[MessageId["
|
|
33
|
-
MessageId[MessageId["
|
|
34
|
-
MessageId[MessageId["
|
|
35
|
-
MessageId[MessageId["
|
|
36
|
-
MessageId[MessageId["
|
|
37
|
-
MessageId[MessageId["
|
|
38
|
-
MessageId[MessageId["
|
|
39
|
-
MessageId[MessageId["
|
|
40
|
-
MessageId[MessageId["
|
|
41
|
-
MessageId[MessageId["
|
|
42
|
-
MessageId[MessageId["
|
|
43
|
-
MessageId[MessageId["
|
|
44
|
-
MessageId[MessageId["
|
|
45
|
-
MessageId[MessageId["
|
|
46
|
-
MessageId[MessageId["
|
|
47
|
-
MessageId[MessageId["
|
|
48
|
-
MessageId[MessageId["
|
|
49
|
-
MessageId[MessageId["
|
|
50
|
-
MessageId[MessageId["
|
|
51
|
-
MessageId[MessageId["
|
|
52
|
-
MessageId[MessageId["
|
|
53
|
-
MessageId[MessageId["
|
|
54
|
-
MessageId[MessageId["
|
|
55
|
-
MessageId[MessageId["
|
|
56
|
-
MessageId[MessageId["
|
|
57
|
-
MessageId[MessageId["
|
|
58
|
-
MessageId[MessageId["
|
|
59
|
-
MessageId[MessageId["
|
|
60
|
-
MessageId[MessageId["
|
|
61
|
-
MessageId[MessageId["
|
|
62
|
-
MessageId[MessageId["
|
|
63
|
-
MessageId[MessageId["
|
|
64
|
-
MessageId[MessageId["
|
|
65
|
-
MessageId[MessageId["
|
|
66
|
-
MessageId[MessageId["
|
|
67
|
-
MessageId[MessageId["
|
|
68
|
-
MessageId[MessageId["
|
|
69
|
-
MessageId[MessageId["
|
|
70
|
-
MessageId[MessageId["
|
|
71
|
-
MessageId[MessageId["
|
|
72
|
-
MessageId[MessageId["
|
|
73
|
-
MessageId[MessageId["
|
|
74
|
-
MessageId[MessageId["
|
|
75
|
-
MessageId[MessageId["
|
|
76
|
-
MessageId[MessageId["
|
|
77
|
-
MessageId[MessageId["
|
|
78
|
-
MessageId[MessageId["
|
|
79
|
-
MessageId[MessageId["
|
|
80
|
-
MessageId[MessageId["
|
|
81
|
-
MessageId[MessageId["
|
|
82
|
-
MessageId[MessageId["
|
|
83
|
-
MessageId[MessageId["
|
|
84
|
-
MessageId[MessageId["
|
|
85
|
-
MessageId[MessageId["
|
|
86
|
-
MessageId[MessageId["
|
|
87
|
-
MessageId[MessageId["
|
|
88
|
-
MessageId[MessageId["
|
|
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 = {}));
|
package/dist/web-app-manifest.js
CHANGED
|
@@ -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
|
|
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:
|
|
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
|
}));
|
package/fixtures/16x16.png
CHANGED
|
File without changes
|
package/fixtures/180x180.png
CHANGED
|
File without changes
|
package/fixtures/192x192.png
CHANGED
|
File without changes
|
package/fixtures/32x32.png
CHANGED
|
File without changes
|
package/fixtures/48x48.png
CHANGED
|
File without changes
|
package/fixtures/512x512.png
CHANGED
|
File without changes
|
package/fixtures/96x96.png
CHANGED
|
File without changes
|
package/fixtures/happy-face.svg
CHANGED
|
File without changes
|
|
File without changes
|
package/fixtures/non-square.png
CHANGED
|
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.
|
|
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": "
|
|
43
|
+
"gitHead": "25d06206eedd021db005448c6b2cf015f6cfc3cf"
|
|
44
44
|
}
|
package/src/check.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/src/desktop/desktop.ts
CHANGED
|
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
|
+
})
|