@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/README.md
CHANGED
|
File without changes
|
package/dist/desktop/ico.js
CHANGED
|
@@ -36,21 +36,16 @@ const checkIcoFavicon = (url, head, fetcher) => __awaiter(void 0, void 0, void 0
|
|
|
36
36
|
];
|
|
37
37
|
let iconUrl = null;
|
|
38
38
|
let images;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
status: types_1.CheckerStatus.Error,
|
|
42
|
-
id: types_1.MessageId.noIcoFavicon,
|
|
43
|
-
text: 'There is no ICO favicon'
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
else if (icos.length > 1) {
|
|
39
|
+
let isDeclared = false;
|
|
40
|
+
if (icos.length > 1) {
|
|
47
41
|
messages.push({
|
|
48
42
|
status: types_1.CheckerStatus.Error,
|
|
49
43
|
id: types_1.MessageId.multipleIcoFavicons,
|
|
50
44
|
text: `There are ${icos.length} ICO favicons`
|
|
51
45
|
});
|
|
52
46
|
}
|
|
53
|
-
else {
|
|
47
|
+
else if (icos.length === 1) {
|
|
48
|
+
isDeclared = true;
|
|
54
49
|
messages.push({
|
|
55
50
|
status: types_1.CheckerStatus.Ok,
|
|
56
51
|
id: types_1.MessageId.icoFaviconDeclared,
|
|
@@ -66,15 +61,35 @@ const checkIcoFavicon = (url, head, fetcher) => __awaiter(void 0, void 0, void 0
|
|
|
66
61
|
}
|
|
67
62
|
else {
|
|
68
63
|
iconUrl = (0, helper_1.mergeUrlAndPath)(url, href);
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// No declared ICO favicon, try the implicit /favicon.ico convention
|
|
68
|
+
iconUrl = (0, helper_1.mergeUrlAndPath)(url, '/favicon.ico');
|
|
69
|
+
}
|
|
70
|
+
// If we have an iconUrl (either from declaration or implicit), try to fetch it
|
|
71
|
+
if (iconUrl) {
|
|
72
|
+
const iconResponse = yield fetcher(iconUrl, 'image/x-icon');
|
|
73
|
+
if (iconResponse.status === 404) {
|
|
74
|
+
if (isDeclared) {
|
|
71
75
|
messages.push({
|
|
72
76
|
status: types_1.CheckerStatus.Error,
|
|
73
77
|
id: types_1.MessageId.icoFavicon404,
|
|
74
78
|
text: `ICO favicon not found at ${iconUrl}`
|
|
75
79
|
});
|
|
76
80
|
}
|
|
77
|
-
else
|
|
81
|
+
else {
|
|
82
|
+
// Implicit favicon not found, report no ICO favicon
|
|
83
|
+
messages.push({
|
|
84
|
+
status: types_1.CheckerStatus.Error,
|
|
85
|
+
id: types_1.MessageId.noIcoFavicon,
|
|
86
|
+
text: 'There is no ICO favicon'
|
|
87
|
+
});
|
|
88
|
+
iconUrl = null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (iconResponse.status >= 300 || !iconResponse.readableStream) {
|
|
92
|
+
if (isDeclared) {
|
|
78
93
|
messages.push({
|
|
79
94
|
status: types_1.CheckerStatus.Error,
|
|
80
95
|
id: types_1.MessageId.icoFaviconCannotGet,
|
|
@@ -82,42 +97,57 @@ const checkIcoFavicon = (url, head, fetcher) => __awaiter(void 0, void 0, void 0
|
|
|
82
97
|
});
|
|
83
98
|
}
|
|
84
99
|
else {
|
|
100
|
+
// Implicit favicon cannot be fetched, report no ICO favicon
|
|
101
|
+
messages.push({
|
|
102
|
+
status: types_1.CheckerStatus.Error,
|
|
103
|
+
id: types_1.MessageId.noIcoFavicon,
|
|
104
|
+
text: 'There is no ICO favicon'
|
|
105
|
+
});
|
|
106
|
+
iconUrl = null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
if (!isDeclared) {
|
|
111
|
+
messages.push({
|
|
112
|
+
status: types_1.CheckerStatus.Ok,
|
|
113
|
+
id: types_1.MessageId.icoFaviconImplicitInRoot,
|
|
114
|
+
text: 'An implicit ICO favicon is found at /favicon.ico'
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
messages.push({
|
|
118
|
+
status: types_1.CheckerStatus.Ok,
|
|
119
|
+
id: types_1.MessageId.icoFaviconDownloadable,
|
|
120
|
+
text: 'ICO favicon found'
|
|
121
|
+
});
|
|
122
|
+
const iconBuffer = yield (0, helper_1.readableStreamToBuffer)(iconResponse.readableStream);
|
|
123
|
+
images = (0, decode_ico_1.default)(iconBuffer);
|
|
124
|
+
const imageSizes = images.map(image => `${image.width}x${image.height}`);
|
|
125
|
+
const expectedSizes = exports.IcoFaviconSizes.map(size => `${size}x${size}`);
|
|
126
|
+
const extraSizes = imageSizes.filter(size => !expectedSizes.includes(size));
|
|
127
|
+
if (extraSizes.length > 0) {
|
|
128
|
+
messages.push({
|
|
129
|
+
status: types_1.CheckerStatus.Warning,
|
|
130
|
+
id: types_1.MessageId.icoFaviconExtraSizes,
|
|
131
|
+
text: `Extra sizes found in ICO favicon: ${extraSizes.join(', ')}`
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const missingSizes = expectedSizes.filter(size => !imageSizes.includes(size));
|
|
135
|
+
if (missingSizes.length > 0) {
|
|
136
|
+
messages.push({
|
|
137
|
+
status: types_1.CheckerStatus.Warning,
|
|
138
|
+
id: types_1.MessageId.icoFaviconMissingSizes,
|
|
139
|
+
text: `Missing sizes in ICO favicon: ${missingSizes.join(', ')}`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (extraSizes.length === 0 && missingSizes.length === 0) {
|
|
85
143
|
messages.push({
|
|
86
144
|
status: types_1.CheckerStatus.Ok,
|
|
87
|
-
id: types_1.MessageId.
|
|
88
|
-
text:
|
|
145
|
+
id: types_1.MessageId.icoFaviconExpectedSizes,
|
|
146
|
+
text: `The ICO favicon has the expected sizes (${imageSizes.join(', ')})`
|
|
89
147
|
});
|
|
90
|
-
const iconBuffer = yield (0, helper_1.readableStreamToBuffer)(iconResponse.readableStream);
|
|
91
|
-
images = yield (0, decode_ico_1.default)(iconBuffer);
|
|
92
|
-
const imageSizes = images.map(image => `${image.width}x${image.height}`);
|
|
93
|
-
const expectedSizes = exports.IcoFaviconSizes.map(size => `${size}x${size}`);
|
|
94
|
-
const extraSizes = imageSizes.filter(size => !expectedSizes.includes(size));
|
|
95
|
-
if (extraSizes.length > 0) {
|
|
96
|
-
messages.push({
|
|
97
|
-
status: types_1.CheckerStatus.Warning,
|
|
98
|
-
id: types_1.MessageId.icoFaviconExtraSizes,
|
|
99
|
-
text: `Extra sizes found in ICO favicon: ${extraSizes.join(', ')}`
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
const missingSizes = expectedSizes.filter(size => !imageSizes.includes(size));
|
|
103
|
-
if (missingSizes.length > 0) {
|
|
104
|
-
messages.push({
|
|
105
|
-
status: types_1.CheckerStatus.Warning,
|
|
106
|
-
id: types_1.MessageId.icoFaviconMissingSizes,
|
|
107
|
-
text: `Missing sizes in ICO favicon: ${missingSizes.join(', ')}`
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
if (extraSizes.length === 0 && missingSizes.length === 0) {
|
|
111
|
-
messages.push({
|
|
112
|
-
status: types_1.CheckerStatus.Ok,
|
|
113
|
-
id: types_1.MessageId.icoFaviconExpectedSizes,
|
|
114
|
-
text: `The ICO favicon has the expected sizes (${imageSizes.join(', ')})`
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
148
|
}
|
|
118
149
|
}
|
|
119
150
|
}
|
|
120
|
-
let content = null;
|
|
121
151
|
const theIcon = {
|
|
122
152
|
content: null,
|
|
123
153
|
url: iconUrl,
|
|
@@ -127,7 +157,7 @@ const checkIcoFavicon = (url, head, fetcher) => __awaiter(void 0, void 0, void 0
|
|
|
127
157
|
if (images) {
|
|
128
158
|
const image = images[0];
|
|
129
159
|
const mimeType = (image.type === "bmp") ? "image/bmp" : "image/png";
|
|
130
|
-
theIcon.content =
|
|
160
|
+
theIcon.content = (0, helper_1.bufferToDataUrl)(Buffer.from(image.data.buffer, image.data.byteOffset, image.data.byteLength), mimeType);
|
|
131
161
|
theIcon.width = image.width;
|
|
132
162
|
theIcon.height = image.height;
|
|
133
163
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
13
|
+
const ico_1 = require("./ico");
|
|
14
|
+
const types_1 = require("../types");
|
|
15
|
+
const helper_1 = require("../helper");
|
|
16
|
+
const test_helper_1 = require("../test-helper");
|
|
17
|
+
const runIcoTest = (headFragment_1, output_1, ...args_1) => __awaiter(void 0, [headFragment_1, output_1, ...args_1], void 0, function* (headFragment, output, fetchDatabase = {}, checkContent = true) {
|
|
18
|
+
const root = headFragment ? (0, node_html_parser_1.parse)(headFragment) : null;
|
|
19
|
+
const result = yield (0, ico_1.checkIcoFavicon)('https://example.com/', root, (0, test_helper_1.testFetcher)(fetchDatabase));
|
|
20
|
+
const filteredMessages = result.messages.map(m => ({ status: m.status, id: m.id }));
|
|
21
|
+
expect(filteredMessages).toEqual(output.messages);
|
|
22
|
+
// Check icon properties - icon is always returned by checkIcoFavicon
|
|
23
|
+
const resultIcon = result.icon;
|
|
24
|
+
const outputIcon = output.icon;
|
|
25
|
+
expect(resultIcon.url).toEqual(outputIcon.url);
|
|
26
|
+
expect(resultIcon.width).toEqual(outputIcon.width);
|
|
27
|
+
expect(resultIcon.height).toEqual(outputIcon.height);
|
|
28
|
+
// For content, just check if it's null or not null unless exact match is needed
|
|
29
|
+
if (checkContent && outputIcon.content === null) {
|
|
30
|
+
expect(resultIcon.content).toBeNull();
|
|
31
|
+
}
|
|
32
|
+
else if (checkContent && outputIcon.content !== null) {
|
|
33
|
+
expect(resultIcon.content).not.toBeNull();
|
|
34
|
+
expect(resultIcon.content).toMatch(/^data:image\/(png|bmp);base64,/);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
test('checkIcoFavicon - noHead', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
yield runIcoTest(null, {
|
|
39
|
+
messages: [{
|
|
40
|
+
status: types_1.CheckerStatus.Error,
|
|
41
|
+
id: types_1.MessageId.noHead,
|
|
42
|
+
}],
|
|
43
|
+
icon: {
|
|
44
|
+
content: null,
|
|
45
|
+
url: null,
|
|
46
|
+
width: null,
|
|
47
|
+
height: null,
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}));
|
|
51
|
+
test('checkIcoFavicon - noIcoFavicon', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
yield runIcoTest(`<title>Some text</title>`, {
|
|
53
|
+
messages: [{
|
|
54
|
+
status: types_1.CheckerStatus.Error,
|
|
55
|
+
id: types_1.MessageId.noIcoFavicon,
|
|
56
|
+
}],
|
|
57
|
+
icon: {
|
|
58
|
+
content: null,
|
|
59
|
+
url: null,
|
|
60
|
+
width: null,
|
|
61
|
+
height: null,
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}));
|
|
65
|
+
test('checkIcoFavicon - implicit /favicon.ico when not declared', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const testIconPath = './fixtures/simple-ico.ico';
|
|
67
|
+
yield runIcoTest(`<title>Some text</title>`, {
|
|
68
|
+
messages: [{
|
|
69
|
+
status: types_1.CheckerStatus.Ok,
|
|
70
|
+
id: types_1.MessageId.icoFaviconImplicitInRoot,
|
|
71
|
+
}, {
|
|
72
|
+
status: types_1.CheckerStatus.Ok,
|
|
73
|
+
id: types_1.MessageId.icoFaviconDownloadable,
|
|
74
|
+
}, {
|
|
75
|
+
status: types_1.CheckerStatus.Ok,
|
|
76
|
+
id: types_1.MessageId.icoFaviconExpectedSizes,
|
|
77
|
+
}],
|
|
78
|
+
icon: {
|
|
79
|
+
content: "data:image/png;base64,placeholder", // Will be checked for format only
|
|
80
|
+
url: 'https://example.com/favicon.ico',
|
|
81
|
+
width: 48,
|
|
82
|
+
height: 48,
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
'https://example.com/favicon.ico': {
|
|
86
|
+
status: 200,
|
|
87
|
+
contentType: 'image/x-icon',
|
|
88
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIconPath)
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}));
|
|
92
|
+
test('checkIcoFavicon - multipleIcoFavicons with shortcut icon', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
+
yield runIcoTest(`
|
|
94
|
+
<link rel="shortcut icon" href="/favicon1.ico" />
|
|
95
|
+
<link rel="shortcut icon" href="/favicon2.ico" />
|
|
96
|
+
`, {
|
|
97
|
+
messages: [{
|
|
98
|
+
status: types_1.CheckerStatus.Error,
|
|
99
|
+
id: types_1.MessageId.multipleIcoFavicons,
|
|
100
|
+
}],
|
|
101
|
+
icon: {
|
|
102
|
+
content: null,
|
|
103
|
+
url: null,
|
|
104
|
+
width: null,
|
|
105
|
+
height: null,
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}));
|
|
109
|
+
test('checkIcoFavicon - multipleIcoFavicons with type="image/x-icon"', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
yield runIcoTest(`
|
|
111
|
+
<link rel="icon" type="image/x-icon" href="/favicon1.ico" />
|
|
112
|
+
<link rel="icon" type="image/x-icon" href="/favicon2.ico" />
|
|
113
|
+
`, {
|
|
114
|
+
messages: [{
|
|
115
|
+
status: types_1.CheckerStatus.Error,
|
|
116
|
+
id: types_1.MessageId.multipleIcoFavicons,
|
|
117
|
+
}],
|
|
118
|
+
icon: {
|
|
119
|
+
content: null,
|
|
120
|
+
url: null,
|
|
121
|
+
width: null,
|
|
122
|
+
height: null,
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}));
|
|
126
|
+
test('checkIcoFavicon - icoFaviconDeclared & noIcoFaviconHref', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
+
yield runIcoTest(`<link rel="shortcut icon" />`, {
|
|
128
|
+
messages: [{
|
|
129
|
+
status: types_1.CheckerStatus.Ok,
|
|
130
|
+
id: types_1.MessageId.icoFaviconDeclared,
|
|
131
|
+
}, {
|
|
132
|
+
status: types_1.CheckerStatus.Error,
|
|
133
|
+
id: types_1.MessageId.noIcoFaviconHref,
|
|
134
|
+
}],
|
|
135
|
+
icon: {
|
|
136
|
+
content: null,
|
|
137
|
+
url: null,
|
|
138
|
+
width: null,
|
|
139
|
+
height: null,
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}));
|
|
143
|
+
test('checkIcoFavicon - icoFaviconDeclared & icoFavicon404', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
yield runIcoTest(`<link rel="shortcut icon" href="/favicon.ico" />`, {
|
|
145
|
+
messages: [{
|
|
146
|
+
status: types_1.CheckerStatus.Ok,
|
|
147
|
+
id: types_1.MessageId.icoFaviconDeclared,
|
|
148
|
+
}, {
|
|
149
|
+
status: types_1.CheckerStatus.Error,
|
|
150
|
+
id: types_1.MessageId.icoFavicon404,
|
|
151
|
+
}],
|
|
152
|
+
icon: {
|
|
153
|
+
content: null,
|
|
154
|
+
url: 'https://example.com/favicon.ico',
|
|
155
|
+
width: null,
|
|
156
|
+
height: null,
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}));
|
|
160
|
+
test('checkIcoFavicon - icoFaviconDeclared & icoFaviconCannotGet', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
+
yield runIcoTest(`<link rel="shortcut icon" href="/favicon.ico" />`, {
|
|
162
|
+
messages: [{
|
|
163
|
+
status: types_1.CheckerStatus.Ok,
|
|
164
|
+
id: types_1.MessageId.icoFaviconDeclared,
|
|
165
|
+
}, {
|
|
166
|
+
status: types_1.CheckerStatus.Error,
|
|
167
|
+
id: types_1.MessageId.icoFaviconCannotGet,
|
|
168
|
+
}],
|
|
169
|
+
icon: {
|
|
170
|
+
content: null,
|
|
171
|
+
url: 'https://example.com/favicon.ico',
|
|
172
|
+
width: null,
|
|
173
|
+
height: null,
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
'https://example.com/favicon.ico': {
|
|
177
|
+
status: 403,
|
|
178
|
+
contentType: 'image/x-icon'
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}));
|
|
182
|
+
test('checkIcoFavicon - icoFaviconDeclared & icoFaviconDownloadable & icoFaviconExpectedSizes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
const testIconPath = './fixtures/simple-ico.ico';
|
|
184
|
+
yield runIcoTest(`<link rel="shortcut icon" href="/favicon.ico" />`, {
|
|
185
|
+
messages: [{
|
|
186
|
+
status: types_1.CheckerStatus.Ok,
|
|
187
|
+
id: types_1.MessageId.icoFaviconDeclared,
|
|
188
|
+
}, {
|
|
189
|
+
status: types_1.CheckerStatus.Ok,
|
|
190
|
+
id: types_1.MessageId.icoFaviconDownloadable,
|
|
191
|
+
}, {
|
|
192
|
+
status: types_1.CheckerStatus.Ok,
|
|
193
|
+
id: types_1.MessageId.icoFaviconExpectedSizes,
|
|
194
|
+
}],
|
|
195
|
+
icon: {
|
|
196
|
+
content: "data:image/png;base64,placeholder", // Will be checked for format only
|
|
197
|
+
url: 'https://example.com/favicon.ico',
|
|
198
|
+
width: 48,
|
|
199
|
+
height: 48,
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
'https://example.com/favicon.ico': {
|
|
203
|
+
status: 200,
|
|
204
|
+
contentType: 'image/x-icon',
|
|
205
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIconPath)
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}));
|
|
209
|
+
test('checkIcoFavicon - using type="image/x-icon"', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
210
|
+
const testIconPath = './fixtures/simple-ico.ico';
|
|
211
|
+
yield runIcoTest(`<link rel="icon" type="image/x-icon" href="/favicon.ico" />`, {
|
|
212
|
+
messages: [{
|
|
213
|
+
status: types_1.CheckerStatus.Ok,
|
|
214
|
+
id: types_1.MessageId.icoFaviconDeclared,
|
|
215
|
+
}, {
|
|
216
|
+
status: types_1.CheckerStatus.Ok,
|
|
217
|
+
id: types_1.MessageId.icoFaviconDownloadable,
|
|
218
|
+
}, {
|
|
219
|
+
status: types_1.CheckerStatus.Ok,
|
|
220
|
+
id: types_1.MessageId.icoFaviconExpectedSizes,
|
|
221
|
+
}],
|
|
222
|
+
icon: {
|
|
223
|
+
content: "data:image/png;base64,placeholder", // Will be checked for format only
|
|
224
|
+
url: 'https://example.com/favicon.ico',
|
|
225
|
+
width: 48,
|
|
226
|
+
height: 48,
|
|
227
|
+
}
|
|
228
|
+
}, {
|
|
229
|
+
'https://example.com/favicon.ico': {
|
|
230
|
+
status: 200,
|
|
231
|
+
contentType: 'image/x-icon',
|
|
232
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIconPath)
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}));
|
|
236
|
+
// For https://github.com/RealFaviconGenerator/core/issues/2
|
|
237
|
+
test('checkIcoFavicon - Protocol-relative URL', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
238
|
+
const testIconPath = './fixtures/simple-ico.ico';
|
|
239
|
+
yield runIcoTest(`<link rel="shortcut icon" href="//example.com/favicon.ico" />`, {
|
|
240
|
+
messages: [{
|
|
241
|
+
status: types_1.CheckerStatus.Ok,
|
|
242
|
+
id: types_1.MessageId.icoFaviconDeclared,
|
|
243
|
+
}, {
|
|
244
|
+
status: types_1.CheckerStatus.Ok,
|
|
245
|
+
id: types_1.MessageId.icoFaviconDownloadable,
|
|
246
|
+
}, {
|
|
247
|
+
status: types_1.CheckerStatus.Ok,
|
|
248
|
+
id: types_1.MessageId.icoFaviconExpectedSizes,
|
|
249
|
+
}],
|
|
250
|
+
icon: {
|
|
251
|
+
content: "data:image/png;base64,placeholder", // Will be checked for format only
|
|
252
|
+
url: 'https://example.com/favicon.ico',
|
|
253
|
+
width: 48,
|
|
254
|
+
height: 48,
|
|
255
|
+
}
|
|
256
|
+
}, {
|
|
257
|
+
'https://example.com/favicon.ico': {
|
|
258
|
+
status: 200,
|
|
259
|
+
contentType: 'image/x-icon',
|
|
260
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIconPath)
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}));
|
package/dist/touch-icon.js
CHANGED
|
@@ -59,14 +59,14 @@ const checkTouchIconTitle = (baseUrl_1, head_1, ...args_1) => __awaiter(void 0,
|
|
|
59
59
|
exports.checkTouchIconTitle = checkTouchIconTitle;
|
|
60
60
|
const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [baseUrl_2, head_2, ...args_2], void 0, function* (baseUrl, head, fetcher = helper_1.fetchFetcher) {
|
|
61
61
|
const messages = [];
|
|
62
|
-
let
|
|
62
|
+
let icon = null;
|
|
63
63
|
if (!head) {
|
|
64
64
|
messages.push({
|
|
65
65
|
status: types_1.CheckerStatus.Error,
|
|
66
66
|
id: types_1.MessageId.noHead,
|
|
67
67
|
text: 'No <head> element'
|
|
68
68
|
});
|
|
69
|
-
return { messages,
|
|
69
|
+
return { messages, icon };
|
|
70
70
|
}
|
|
71
71
|
const iconMarkup = head.querySelectorAll("link[rel='apple-touch-icon']");
|
|
72
72
|
if (iconMarkup.length === 0) {
|
|
@@ -75,7 +75,7 @@ const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [
|
|
|
75
75
|
id: types_1.MessageId.noTouchIcon,
|
|
76
76
|
text: 'No touch icon declared'
|
|
77
77
|
});
|
|
78
|
-
return { messages,
|
|
78
|
+
return { messages, icon };
|
|
79
79
|
}
|
|
80
80
|
messages.push({
|
|
81
81
|
status: types_1.CheckerStatus.Ok,
|
|
@@ -97,7 +97,7 @@ const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [
|
|
|
97
97
|
id: types_1.MessageId.noTouchIconHref,
|
|
98
98
|
text: 'The touch icon has no href'
|
|
99
99
|
});
|
|
100
|
-
return { messages,
|
|
100
|
+
return { messages, icon };
|
|
101
101
|
}
|
|
102
102
|
const touchIconUrl = (0, helper_1.mergeUrlAndPath)(baseUrl, iconHref);
|
|
103
103
|
const processor = {
|
|
@@ -158,8 +158,8 @@ const checkTouchIconIcon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [
|
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
return { messages,
|
|
161
|
+
icon = yield (0, helper_1.checkIcon)(touchIconUrl, processor, fetcher, undefined);
|
|
162
|
+
return { messages, icon };
|
|
163
163
|
});
|
|
164
164
|
exports.checkTouchIconIcon = checkTouchIconIcon;
|
|
165
165
|
const getDuplicatedSizes = (sizes) => {
|
|
@@ -173,7 +173,7 @@ const checkTouchIcon = (baseUrl_3, head_3, ...args_3) => __awaiter(void 0, [base
|
|
|
173
173
|
return {
|
|
174
174
|
messages: [...titleReport.messages, ...iconReport.messages],
|
|
175
175
|
appTitle: titleReport.appTitle,
|
|
176
|
-
|
|
176
|
+
icon: iconReport.icon
|
|
177
177
|
};
|
|
178
178
|
});
|
|
179
179
|
exports.checkTouchIcon = checkTouchIcon;
|
package/dist/touch-icon.test.js
CHANGED
|
@@ -58,8 +58,8 @@ const runCheckTouchIconTest = (headFragment_2, output_2, ...args_2) => __awaiter
|
|
|
58
58
|
const filteredMessages = result.messages.map(m => ({ status: m.status, id: m.id }));
|
|
59
59
|
expect({
|
|
60
60
|
messages: filteredMessages,
|
|
61
|
-
|
|
62
|
-
}).toEqual(Object.assign(Object.assign({}, output), {
|
|
61
|
+
icon: result.icon
|
|
62
|
+
}).toEqual(Object.assign(Object.assign({}, output), { icon: output.icon || null }));
|
|
63
63
|
});
|
|
64
64
|
test('checkTouchIcon - noHead', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
65
|
yield runCheckTouchIconTest(null, { messages: [{
|
|
@@ -83,7 +83,13 @@ test('checkTouchIcon - multipleTouchIcon - no size', () => __awaiter(void 0, voi
|
|
|
83
83
|
}, {
|
|
84
84
|
status: types_1.CheckerStatus.Error,
|
|
85
85
|
id: types_1.MessageId.duplicatedTouchIconSizes,
|
|
86
|
-
}]
|
|
86
|
+
}], icon: {
|
|
87
|
+
content: null,
|
|
88
|
+
url: 'https://example.com/some-icon.png',
|
|
89
|
+
width: null,
|
|
90
|
+
height: null
|
|
91
|
+
},
|
|
92
|
+
}, {
|
|
87
93
|
'https://example.com/some-icon.png': {
|
|
88
94
|
status: 200,
|
|
89
95
|
contentType: 'image/png',
|
|
@@ -106,7 +112,14 @@ test('checkTouchIcon - multipleTouchIcon - specific size', () => __awaiter(void
|
|
|
106
112
|
}, {
|
|
107
113
|
status: types_1.CheckerStatus.Error,
|
|
108
114
|
id: types_1.MessageId.duplicatedTouchIconSizes,
|
|
109
|
-
}]
|
|
115
|
+
}],
|
|
116
|
+
icon: {
|
|
117
|
+
content: null,
|
|
118
|
+
url: 'https://example.com/some-icon.png',
|
|
119
|
+
width: null,
|
|
120
|
+
height: null
|
|
121
|
+
},
|
|
122
|
+
}, {
|
|
110
123
|
'https://example.com/some-icon.png': {
|
|
111
124
|
status: 200,
|
|
112
125
|
contentType: 'image/png',
|
|
@@ -132,7 +145,12 @@ test('checkTouchIcon - Regular case', () => __awaiter(void 0, void 0, void 0, fu
|
|
|
132
145
|
}, {
|
|
133
146
|
status: types_1.CheckerStatus.Ok,
|
|
134
147
|
id: types_1.MessageId.touchIconSquare
|
|
135
|
-
}],
|
|
148
|
+
}], icon: {
|
|
149
|
+
content: (0, helper_1.bufferToDataUrl)(yield (0, helper_1.readableStreamToBuffer)(yield (0, helper_1.filePathToReadableStream)(testIcon)), 'image/png'),
|
|
150
|
+
url: 'https://example.com/some-other-icon.png',
|
|
151
|
+
width: 180,
|
|
152
|
+
height: 180,
|
|
153
|
+
}
|
|
136
154
|
}, {
|
|
137
155
|
'https://example.com/some-other-icon.png': {
|
|
138
156
|
status: 200,
|