@realfavicongenerator/check-favicon 0.4.3 → 0.4.5
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/desktop/desktop.js
CHANGED
|
@@ -143,7 +143,7 @@ const checkPngFavicon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [bas
|
|
|
143
143
|
id: types_1.MessageId.desktopPngFaviconDeclared,
|
|
144
144
|
text: `The ${size} desktop PNG favicon is declared`
|
|
145
145
|
});
|
|
146
|
-
const href =
|
|
146
|
+
const href = sizedIconMarkup[0].attributes.href;
|
|
147
147
|
if (!href) {
|
|
148
148
|
messages.push({
|
|
149
149
|
status: types_1.CheckerStatus.Error,
|
|
@@ -14,26 +14,26 @@ const desktop_1 = require("./desktop");
|
|
|
14
14
|
const types_1 = require("../types");
|
|
15
15
|
const helper_1 = require("../helper");
|
|
16
16
|
const test_helper_1 = require("../test-helper");
|
|
17
|
-
const
|
|
17
|
+
const runSvgTest = (headFragment_1, output_1, ...args_1) => __awaiter(void 0, [headFragment_1, output_1, ...args_1], void 0, function* (headFragment, output, fetchDatabase = {}) {
|
|
18
18
|
const root = headFragment ? (0, node_html_parser_1.parse)(headFragment) : null;
|
|
19
19
|
const result = yield (0, desktop_1.checkSvgFavicon)('https://example.com/', root, (0, test_helper_1.testFetcher)(fetchDatabase));
|
|
20
20
|
const filteredMessages = result.map(m => ({ status: m.status, id: m.id }));
|
|
21
21
|
expect(filteredMessages).toEqual(output);
|
|
22
22
|
});
|
|
23
23
|
test('checkSvgFavicon - noHead', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
yield
|
|
24
|
+
yield runSvgTest(null, [{
|
|
25
25
|
status: types_1.CheckerStatus.Error,
|
|
26
26
|
id: types_1.MessageId.noHead,
|
|
27
27
|
}]);
|
|
28
28
|
}));
|
|
29
29
|
test('checkSvgFavicon - noSvgFavicon', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
yield
|
|
30
|
+
yield runSvgTest(`<title>SOme text</title>`, [{
|
|
31
31
|
status: types_1.CheckerStatus.Error,
|
|
32
32
|
id: types_1.MessageId.noSvgFavicon,
|
|
33
33
|
}]);
|
|
34
34
|
}));
|
|
35
35
|
test('checkSvgFavicon - multipleSvgFavicons', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
yield
|
|
36
|
+
yield runSvgTest(`
|
|
37
37
|
<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />
|
|
38
38
|
<link rel="icon" type="image/svg+xml" href="/another-icon.svg" />
|
|
39
39
|
`, [{
|
|
@@ -42,7 +42,7 @@ test('checkSvgFavicon - multipleSvgFavicons', () => __awaiter(void 0, void 0, vo
|
|
|
42
42
|
}]);
|
|
43
43
|
}));
|
|
44
44
|
test('checkSvgFavicon - svgFaviconDeclared & noSvgFaviconHref', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
yield
|
|
45
|
+
yield runSvgTest(`<link rel="icon" type="image/svg+xml" />`, [{
|
|
46
46
|
status: types_1.CheckerStatus.Ok,
|
|
47
47
|
id: types_1.MessageId.svgFaviconDeclared,
|
|
48
48
|
}, {
|
|
@@ -51,7 +51,7 @@ test('checkSvgFavicon - svgFaviconDeclared & noSvgFaviconHref', () => __awaiter(
|
|
|
51
51
|
}]);
|
|
52
52
|
}));
|
|
53
53
|
test('checkSvgFavicon - svgFaviconDeclared & svgFavicon404', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
yield
|
|
54
|
+
yield runSvgTest(`<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />`, [{
|
|
55
55
|
status: types_1.CheckerStatus.Ok,
|
|
56
56
|
id: types_1.MessageId.svgFaviconDeclared,
|
|
57
57
|
}, {
|
|
@@ -60,7 +60,7 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFavicon404', () => __awaiter(voi
|
|
|
60
60
|
}]);
|
|
61
61
|
}));
|
|
62
62
|
test('checkSvgFavicon - svgFaviconDeclared & svgFaviconCannotGet', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
yield
|
|
63
|
+
yield runSvgTest(`<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />`, [{
|
|
64
64
|
status: types_1.CheckerStatus.Ok,
|
|
65
65
|
id: types_1.MessageId.svgFaviconDeclared,
|
|
66
66
|
}, {
|
|
@@ -76,7 +76,7 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFaviconCannotGet', () => __await
|
|
|
76
76
|
test('checkSvgFavicon - svgFaviconDeclared & svgFaviconDownloadable & svgFaviconSquare', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
77
|
const testIconPath = './fixtures/happy-face.svg';
|
|
78
78
|
const serpIcon = yield (0, helper_1.filePathToString)(testIconPath);
|
|
79
|
-
yield
|
|
79
|
+
yield runSvgTest(`<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />`, [
|
|
80
80
|
{
|
|
81
81
|
status: types_1.CheckerStatus.Ok,
|
|
82
82
|
id: types_1.MessageId.svgFaviconDeclared,
|
|
@@ -95,3 +95,44 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFaviconDownloadable & svgFavicon
|
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
}));
|
|
98
|
+
const runPngTest = (headFragment_2, output_2, ...args_2) => __awaiter(void 0, [headFragment_2, output_2, ...args_2], void 0, function* (headFragment, output, fetchDatabase = {}) {
|
|
99
|
+
const root = headFragment ? (0, node_html_parser_1.parse)(headFragment) : null;
|
|
100
|
+
const result = yield (0, desktop_1.checkPngFavicon)('https://example.com/', root, (0, test_helper_1.testFetcher)(fetchDatabase));
|
|
101
|
+
const filteredMessages = result.messages.map(m => ({ status: m.status, id: m.id }));
|
|
102
|
+
expect(filteredMessages).toEqual(output);
|
|
103
|
+
});
|
|
104
|
+
const testIcon16 = './fixtures/16x16.png';
|
|
105
|
+
const testIcon32 = './fixtures/32x32.png';
|
|
106
|
+
const testIcon48 = './fixtures/48x48.png';
|
|
107
|
+
test('checkSvgFavicon - Three PNG icons with different sizes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
yield runPngTest(`
|
|
109
|
+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
|
|
110
|
+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
|
111
|
+
<link rel="icon" type="image/png" sizes="48x48" href="/favicon/favicon-48x48.png">
|
|
112
|
+
`, [{
|
|
113
|
+
status: types_1.CheckerStatus.Ok,
|
|
114
|
+
id: types_1.MessageId.desktopPngFaviconDeclared,
|
|
115
|
+
}, {
|
|
116
|
+
status: types_1.CheckerStatus.Ok,
|
|
117
|
+
id: types_1.MessageId.desktopPngFaviconDownloadable,
|
|
118
|
+
}, {
|
|
119
|
+
status: types_1.CheckerStatus.Ok,
|
|
120
|
+
id: types_1.MessageId.desktopPngFaviconRightSize,
|
|
121
|
+
}], {
|
|
122
|
+
'https://example.com/favicon/favicon-16x16.png': {
|
|
123
|
+
status: 200,
|
|
124
|
+
contentType: 'image/png',
|
|
125
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIcon16),
|
|
126
|
+
},
|
|
127
|
+
'https://example.com/favicon/favicon-32x32.png': {
|
|
128
|
+
status: 200,
|
|
129
|
+
contentType: 'image/png',
|
|
130
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIcon32),
|
|
131
|
+
},
|
|
132
|
+
'https://example.com/favicon/favicon-48x48.png': {
|
|
133
|
+
status: 200,
|
|
134
|
+
contentType: 'image/png',
|
|
135
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIcon48),
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realfavicongenerator/check-favicon",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Check the favicon of a website",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "jest",
|
|
9
|
+
"test:watch": "jest --watch",
|
|
9
10
|
"build": "tsc",
|
|
10
11
|
"prepublishOnly": "npm run build"
|
|
11
12
|
},
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"node-html-parser": "^6.1.13",
|
|
39
40
|
"sharp": "^0.32.6"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ff517731a374ff42747e65aa036b064d1a1f1aa1"
|
|
42
43
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { parse } from 'node-html-parser'
|
|
2
|
-
import { checkSvgFavicon } from "./desktop";
|
|
2
|
+
import { checkPngFavicon, checkSvgFavicon } from "./desktop";
|
|
3
3
|
import { CheckerMessage, CheckerStatus, FetchResponse, MessageId } from '../types';
|
|
4
4
|
import { filePathToReadableStream, filePathToString, stringToReadableStream } from '../helper';
|
|
5
5
|
import { testFetcher } from '../test-helper';
|
|
6
6
|
|
|
7
7
|
type TestOutput = Pick<CheckerMessage, 'id' | 'status'>[];
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const runSvgTest = async (
|
|
10
10
|
headFragment: string | null,
|
|
11
11
|
output: TestOutput,
|
|
12
12
|
fetchDatabase: { [url: string]: FetchResponse } = {}
|
|
@@ -18,21 +18,21 @@ const runTest = async (
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
test('checkSvgFavicon - noHead', async () => {
|
|
21
|
-
await
|
|
21
|
+
await runSvgTest(null, [{
|
|
22
22
|
status: CheckerStatus.Error,
|
|
23
23
|
id: MessageId.noHead,
|
|
24
24
|
}]);
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
test('checkSvgFavicon - noSvgFavicon', async () => {
|
|
28
|
-
await
|
|
28
|
+
await runSvgTest(`<title>SOme text</title>`, [{
|
|
29
29
|
status: CheckerStatus.Error,
|
|
30
30
|
id: MessageId.noSvgFavicon,
|
|
31
31
|
}]);
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
test('checkSvgFavicon - multipleSvgFavicons', async () => {
|
|
35
|
-
await
|
|
35
|
+
await runSvgTest(`
|
|
36
36
|
<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />
|
|
37
37
|
<link rel="icon" type="image/svg+xml" href="/another-icon.svg" />
|
|
38
38
|
`, [{
|
|
@@ -42,7 +42,7 @@ test('checkSvgFavicon - multipleSvgFavicons', async () => {
|
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
test('checkSvgFavicon - svgFaviconDeclared & noSvgFaviconHref', async () => {
|
|
45
|
-
await
|
|
45
|
+
await runSvgTest(`<link rel="icon" type="image/svg+xml" />`, [{
|
|
46
46
|
status: CheckerStatus.Ok,
|
|
47
47
|
id: MessageId.svgFaviconDeclared,
|
|
48
48
|
}, {
|
|
@@ -52,7 +52,7 @@ test('checkSvgFavicon - svgFaviconDeclared & noSvgFaviconHref', async () => {
|
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
test('checkSvgFavicon - svgFaviconDeclared & svgFavicon404', async () => {
|
|
55
|
-
await
|
|
55
|
+
await runSvgTest(`<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />`, [{
|
|
56
56
|
status: CheckerStatus.Ok,
|
|
57
57
|
id: MessageId.svgFaviconDeclared,
|
|
58
58
|
}, {
|
|
@@ -62,7 +62,7 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFavicon404', async () => {
|
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
test('checkSvgFavicon - svgFaviconDeclared & svgFaviconCannotGet', async () => {
|
|
65
|
-
await
|
|
65
|
+
await runSvgTest(`<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />`, [{
|
|
66
66
|
status: CheckerStatus.Ok,
|
|
67
67
|
id: MessageId.svgFaviconDeclared,
|
|
68
68
|
}, {
|
|
@@ -81,7 +81,7 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFaviconDownloadable & svgFavicon
|
|
|
81
81
|
|
|
82
82
|
const serpIcon = await filePathToString(testIconPath);
|
|
83
83
|
|
|
84
|
-
await
|
|
84
|
+
await runSvgTest(`<link rel="icon" type="image/svg+xml" href="/the-icon.svg" />`, [
|
|
85
85
|
{
|
|
86
86
|
status: CheckerStatus.Ok,
|
|
87
87
|
id: MessageId.svgFaviconDeclared,
|
|
@@ -99,3 +99,52 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFaviconDownloadable & svgFavicon
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
})
|
|
102
|
+
|
|
103
|
+
const runPngTest = async (
|
|
104
|
+
headFragment: string | null,
|
|
105
|
+
output: TestOutput,
|
|
106
|
+
fetchDatabase: { [url: string]: FetchResponse } = {}
|
|
107
|
+
) => {
|
|
108
|
+
const root = headFragment ? parse(headFragment) : null;
|
|
109
|
+
const result = await checkPngFavicon('https://example.com/', root, testFetcher(fetchDatabase));
|
|
110
|
+
const filteredMessages = result.messages.map(m => ({ status: m.status, id: m.id }));
|
|
111
|
+
expect(filteredMessages).toEqual(output);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const testIcon16 = './fixtures/16x16.png';
|
|
115
|
+
const testIcon32 = './fixtures/32x32.png';
|
|
116
|
+
const testIcon48 = './fixtures/48x48.png';
|
|
117
|
+
|
|
118
|
+
test('checkSvgFavicon - Three PNG icons with different sizes', async () => {
|
|
119
|
+
await runPngTest(`
|
|
120
|
+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
|
|
121
|
+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
|
122
|
+
<link rel="icon" type="image/png" sizes="48x48" href="/favicon/favicon-48x48.png">
|
|
123
|
+
`, [{
|
|
124
|
+
status: CheckerStatus.Ok,
|
|
125
|
+
id: MessageId.desktopPngFaviconDeclared,
|
|
126
|
+
}, {
|
|
127
|
+
status: CheckerStatus.Ok,
|
|
128
|
+
id: MessageId.desktopPngFaviconDownloadable,
|
|
129
|
+
}, {
|
|
130
|
+
status: CheckerStatus.Ok,
|
|
131
|
+
id: MessageId.desktopPngFaviconRightSize,
|
|
132
|
+
}],
|
|
133
|
+
{
|
|
134
|
+
'https://example.com/favicon/favicon-16x16.png': {
|
|
135
|
+
status: 200,
|
|
136
|
+
contentType: 'image/png',
|
|
137
|
+
readableStream: await filePathToReadableStream(testIcon16),
|
|
138
|
+
},
|
|
139
|
+
'https://example.com/favicon/favicon-32x32.png': {
|
|
140
|
+
status: 200,
|
|
141
|
+
contentType: 'image/png',
|
|
142
|
+
readableStream: await filePathToReadableStream(testIcon32),
|
|
143
|
+
},
|
|
144
|
+
'https://example.com/favicon/favicon-48x48.png': {
|
|
145
|
+
status: 200,
|
|
146
|
+
contentType: 'image/png',
|
|
147
|
+
readableStream: await filePathToReadableStream(testIcon48),
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
})
|
package/src/desktop/desktop.ts
CHANGED
|
@@ -137,8 +137,8 @@ export const checkPngFavicon = async (baseUrl: string, head: HTMLElement | null,
|
|
|
137
137
|
id: MessageId.desktopPngFaviconDeclared,
|
|
138
138
|
text: `The ${size} desktop PNG favicon is declared`
|
|
139
139
|
});
|
|
140
|
-
|
|
141
|
-
const href =
|
|
140
|
+
|
|
141
|
+
const href = sizedIconMarkup[0].attributes.href;
|
|
142
142
|
if (!href) {
|
|
143
143
|
messages.push({
|
|
144
144
|
status: CheckerStatus.Error,
|