@realfavicongenerator/check-favicon 0.4.5 → 0.4.7
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.d.ts +1 -1
- package/dist/desktop/desktop.js +2 -2
- package/dist/desktop/desktop.test.js +22 -0
- package/dist/helper.js +6 -2
- package/dist/helper.test.js +4 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/fixtures/96x96.png +0 -0
- package/package.json +2 -3
- package/src/desktop/desktop.test.ts +23 -0
- package/src/desktop/desktop.ts +2 -2
- package/src/helper.test.ts +5 -0
- package/src/helper.ts +5 -2
- package/src/types.ts +1 -1
- package/LICENSE +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CheckerMessage, DesktopFaviconReport, Fetcher } from "../types";
|
|
2
2
|
import { HTMLElement } from 'node-html-parser';
|
|
3
|
-
export declare const PngFaviconFileSize =
|
|
3
|
+
export declare const PngFaviconFileSize = 96;
|
|
4
4
|
export declare const checkSvgFavicon: (baseUrl: string, head: HTMLElement | null, fetcher?: Fetcher) => Promise<CheckerMessage[]>;
|
|
5
5
|
export declare const checkSvgFaviconFile: (baseUrl: string, url: string, fetcher: Fetcher) => Promise<CheckerMessage[]>;
|
|
6
6
|
export declare const checkPngFavicon: (baseUrl: string, head: HTMLElement | null, fetcher?: Fetcher) => Promise<DesktopFaviconReport>;
|
package/dist/desktop/desktop.js
CHANGED
|
@@ -17,7 +17,7 @@ const types_1 = require("../types");
|
|
|
17
17
|
const sharp_1 = __importDefault(require("sharp"));
|
|
18
18
|
const helper_1 = require("../helper");
|
|
19
19
|
const ico_1 = require("./ico");
|
|
20
|
-
exports.PngFaviconFileSize =
|
|
20
|
+
exports.PngFaviconFileSize = 96;
|
|
21
21
|
const checkSvgFavicon = (baseUrl_1, head_1, ...args_1) => __awaiter(void 0, [baseUrl_1, head_1, ...args_1], void 0, function* (baseUrl, head, fetcher = helper_1.fetchFetcher) {
|
|
22
22
|
const messages = [];
|
|
23
23
|
if (!head) {
|
|
@@ -133,7 +133,7 @@ const checkPngFavicon = (baseUrl_2, head_2, ...args_2) => __awaiter(void 0, [bas
|
|
|
133
133
|
if (sizedIconMarkup.length === 0) {
|
|
134
134
|
messages.push({
|
|
135
135
|
status: types_1.CheckerStatus.Error,
|
|
136
|
-
id: types_1.MessageId.
|
|
136
|
+
id: types_1.MessageId.no96x96DesktopPngFavicon,
|
|
137
137
|
text: `There is no ${size} desktop PNG favicon`
|
|
138
138
|
});
|
|
139
139
|
}
|
|
@@ -73,6 +73,21 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFaviconCannotGet', () => __await
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
}));
|
|
76
|
+
// For https://github.com/RealFaviconGenerator/core/issues/2
|
|
77
|
+
test('checkSvgFavicon - Protocol-relative URL', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
yield runSvgTest(`<link rel="icon" type="image/svg+xml" href="//example.com/the-icon.svg" />`, [{
|
|
79
|
+
status: types_1.CheckerStatus.Ok,
|
|
80
|
+
id: types_1.MessageId.svgFaviconDeclared,
|
|
81
|
+
}, {
|
|
82
|
+
status: types_1.CheckerStatus.Error,
|
|
83
|
+
id: types_1.MessageId.svgFaviconCannotGet,
|
|
84
|
+
}], {
|
|
85
|
+
'https://example.com/the-icon.svg': {
|
|
86
|
+
status: 403,
|
|
87
|
+
contentType: 'image/svg+xml'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
76
91
|
test('checkSvgFavicon - svgFaviconDeclared & svgFaviconDownloadable & svgFaviconSquare', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
92
|
const testIconPath = './fixtures/happy-face.svg';
|
|
78
93
|
const serpIcon = yield (0, helper_1.filePathToString)(testIconPath);
|
|
@@ -104,11 +119,13 @@ const runPngTest = (headFragment_2, output_2, ...args_2) => __awaiter(void 0, [h
|
|
|
104
119
|
const testIcon16 = './fixtures/16x16.png';
|
|
105
120
|
const testIcon32 = './fixtures/32x32.png';
|
|
106
121
|
const testIcon48 = './fixtures/48x48.png';
|
|
122
|
+
const testIcon96 = './fixtures/96x96.png';
|
|
107
123
|
test('checkSvgFavicon - Three PNG icons with different sizes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
124
|
yield runPngTest(`
|
|
109
125
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
|
|
110
126
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
|
111
127
|
<link rel="icon" type="image/png" sizes="48x48" href="/favicon/favicon-48x48.png">
|
|
128
|
+
<link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png">
|
|
112
129
|
`, [{
|
|
113
130
|
status: types_1.CheckerStatus.Ok,
|
|
114
131
|
id: types_1.MessageId.desktopPngFaviconDeclared,
|
|
@@ -133,6 +150,11 @@ test('checkSvgFavicon - Three PNG icons with different sizes', () => __awaiter(v
|
|
|
133
150
|
status: 200,
|
|
134
151
|
contentType: 'image/png',
|
|
135
152
|
readableStream: yield (0, helper_1.filePathToReadableStream)(testIcon48),
|
|
153
|
+
},
|
|
154
|
+
'https://example.com/favicon/favicon-96x96.png': {
|
|
155
|
+
status: 200,
|
|
156
|
+
contentType: 'image/png',
|
|
157
|
+
readableStream: yield (0, helper_1.filePathToReadableStream)(testIcon96),
|
|
136
158
|
}
|
|
137
159
|
});
|
|
138
160
|
}));
|
package/dist/helper.js
CHANGED
|
@@ -145,8 +145,12 @@ const mergeUrlAndPath = (baseUrl, absoluteOrRelativePath) => {
|
|
|
145
145
|
return absoluteOrRelativePath;
|
|
146
146
|
}
|
|
147
147
|
const url = new URL(baseUrl);
|
|
148
|
-
//
|
|
149
|
-
if (absoluteOrRelativePath.startsWith('
|
|
148
|
+
// Protocol-relative URL
|
|
149
|
+
if (absoluteOrRelativePath.startsWith('//')) {
|
|
150
|
+
return `${url.protocol}${absoluteOrRelativePath}`;
|
|
151
|
+
}
|
|
152
|
+
else if (absoluteOrRelativePath.startsWith('/')) {
|
|
153
|
+
// If the path starts with a slash, replace the pathname
|
|
150
154
|
return `${url.origin}${absoluteOrRelativePath}`;
|
|
151
155
|
}
|
|
152
156
|
else {
|
package/dist/helper.test.js
CHANGED
|
@@ -112,6 +112,10 @@ test('mergeUrlAndPath', () => {
|
|
|
112
112
|
expect((0, helper_1.mergeUrlAndPath)('https://example.com/sub-page', '/some-path')).toBe('https://example.com/some-path');
|
|
113
113
|
expect((0, helper_1.mergeUrlAndPath)('https://example.com/sub-page', 'some/path')).toBe('https://example.com/sub-page/some/path');
|
|
114
114
|
expect((0, helper_1.mergeUrlAndPath)('https://example.com', 'https://elsewhere.com/some-path')).toBe('https://elsewhere.com/some-path');
|
|
115
|
+
// Protocol-relative URL
|
|
116
|
+
// For https://github.com/RealFaviconGenerator/core/issues/2
|
|
117
|
+
expect((0, helper_1.mergeUrlAndPath)('https://example.com', '//elsewhere.com/some-path')).toBe('https://elsewhere.com/some-path');
|
|
118
|
+
expect((0, helper_1.mergeUrlAndPath)('http://example.com', '//elsewhere.com/some-other/path')).toBe('http://elsewhere.com/some-other/path');
|
|
115
119
|
});
|
|
116
120
|
test('parseSizesAttribute', () => {
|
|
117
121
|
expect((0, helper_1.parseSizesAttribute)(null)).toEqual(null);
|
package/dist/types.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare enum MessageId {
|
|
|
25
25
|
icoFaviconMissingSizes = 18,
|
|
26
26
|
icoFaviconExpectedSizes = 19,
|
|
27
27
|
noDesktopPngFavicon = 20,
|
|
28
|
-
|
|
28
|
+
no96x96DesktopPngFavicon = 21,
|
|
29
29
|
desktopPngFaviconDeclared = 22,
|
|
30
30
|
noDesktopPngFaviconHref = 23,
|
|
31
31
|
desktopPngFaviconCannotGet = 24,
|
package/dist/types.js
CHANGED
|
@@ -30,7 +30,7 @@ var MessageId;
|
|
|
30
30
|
MessageId[MessageId["icoFaviconMissingSizes"] = 18] = "icoFaviconMissingSizes";
|
|
31
31
|
MessageId[MessageId["icoFaviconExpectedSizes"] = 19] = "icoFaviconExpectedSizes";
|
|
32
32
|
MessageId[MessageId["noDesktopPngFavicon"] = 20] = "noDesktopPngFavicon";
|
|
33
|
-
MessageId[MessageId["
|
|
33
|
+
MessageId[MessageId["no96x96DesktopPngFavicon"] = 21] = "no96x96DesktopPngFavicon";
|
|
34
34
|
MessageId[MessageId["desktopPngFaviconDeclared"] = 22] = "desktopPngFaviconDeclared";
|
|
35
35
|
MessageId[MessageId["noDesktopPngFaviconHref"] = 23] = "noDesktopPngFaviconHref";
|
|
36
36
|
MessageId[MessageId["desktopPngFaviconCannotGet"] = 24] = "desktopPngFaviconCannotGet";
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realfavicongenerator/check-favicon",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Check the favicon of a website",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,6 +38,5 @@
|
|
|
38
38
|
"decode-ico": "^0.4.1",
|
|
39
39
|
"node-html-parser": "^6.1.13",
|
|
40
40
|
"sharp": "^0.32.6"
|
|
41
|
-
}
|
|
42
|
-
"gitHead": "ff517731a374ff42747e65aa036b064d1a1f1aa1"
|
|
41
|
+
}
|
|
43
42
|
}
|
|
@@ -76,6 +76,22 @@ test('checkSvgFavicon - svgFaviconDeclared & svgFaviconCannotGet', async () => {
|
|
|
76
76
|
});
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
+
// For https://github.com/RealFaviconGenerator/core/issues/2
|
|
80
|
+
test('checkSvgFavicon - Protocol-relative URL', async () => {
|
|
81
|
+
await runSvgTest(`<link rel="icon" type="image/svg+xml" href="//example.com/the-icon.svg" />`, [{
|
|
82
|
+
status: CheckerStatus.Ok,
|
|
83
|
+
id: MessageId.svgFaviconDeclared,
|
|
84
|
+
}, {
|
|
85
|
+
status: CheckerStatus.Error,
|
|
86
|
+
id: MessageId.svgFaviconCannotGet,
|
|
87
|
+
}], {
|
|
88
|
+
'https://example.com/the-icon.svg': {
|
|
89
|
+
status: 403,
|
|
90
|
+
contentType: 'image/svg+xml'
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
})
|
|
94
|
+
|
|
79
95
|
test('checkSvgFavicon - svgFaviconDeclared & svgFaviconDownloadable & svgFaviconSquare', async () => {
|
|
80
96
|
const testIconPath = './fixtures/happy-face.svg';
|
|
81
97
|
|
|
@@ -114,12 +130,14 @@ const runPngTest = async (
|
|
|
114
130
|
const testIcon16 = './fixtures/16x16.png';
|
|
115
131
|
const testIcon32 = './fixtures/32x32.png';
|
|
116
132
|
const testIcon48 = './fixtures/48x48.png';
|
|
133
|
+
const testIcon96 = './fixtures/96x96.png';
|
|
117
134
|
|
|
118
135
|
test('checkSvgFavicon - Three PNG icons with different sizes', async () => {
|
|
119
136
|
await runPngTest(`
|
|
120
137
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
|
|
121
138
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
|
122
139
|
<link rel="icon" type="image/png" sizes="48x48" href="/favicon/favicon-48x48.png">
|
|
140
|
+
<link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png">
|
|
123
141
|
`, [{
|
|
124
142
|
status: CheckerStatus.Ok,
|
|
125
143
|
id: MessageId.desktopPngFaviconDeclared,
|
|
@@ -145,6 +163,11 @@ test('checkSvgFavicon - Three PNG icons with different sizes', async () => {
|
|
|
145
163
|
status: 200,
|
|
146
164
|
contentType: 'image/png',
|
|
147
165
|
readableStream: await filePathToReadableStream(testIcon48),
|
|
166
|
+
},
|
|
167
|
+
'https://example.com/favicon/favicon-96x96.png': {
|
|
168
|
+
status: 200,
|
|
169
|
+
contentType: 'image/png',
|
|
170
|
+
readableStream: await filePathToReadableStream(testIcon96),
|
|
148
171
|
}
|
|
149
172
|
});
|
|
150
173
|
})
|
package/src/desktop/desktop.ts
CHANGED
|
@@ -4,7 +4,7 @@ import sharp from 'sharp'
|
|
|
4
4
|
import { CheckIconProcessor, checkIcon, fetchFetcher, mergeUrlAndPath, readableStreamToString } from "../helper";
|
|
5
5
|
import { checkIcoFavicon } from "./ico";
|
|
6
6
|
|
|
7
|
-
export const PngFaviconFileSize =
|
|
7
|
+
export const PngFaviconFileSize = 96;
|
|
8
8
|
|
|
9
9
|
export const checkSvgFavicon = async (baseUrl: string, head: HTMLElement | null, fetcher: Fetcher = fetchFetcher): Promise<CheckerMessage[]> => {
|
|
10
10
|
const messages: CheckerMessage[] = [];
|
|
@@ -128,7 +128,7 @@ export const checkPngFavicon = async (baseUrl: string, head: HTMLElement | null,
|
|
|
128
128
|
if (sizedIconMarkup.length === 0) {
|
|
129
129
|
messages.push({
|
|
130
130
|
status: CheckerStatus.Error,
|
|
131
|
-
id: MessageId.
|
|
131
|
+
id: MessageId.no96x96DesktopPngFavicon,
|
|
132
132
|
text: `There is no ${size} desktop PNG favicon`
|
|
133
133
|
});
|
|
134
134
|
} else {
|
package/src/helper.test.ts
CHANGED
|
@@ -117,6 +117,11 @@ test('mergeUrlAndPath', () => {
|
|
|
117
117
|
expect(mergeUrlAndPath('https://example.com/sub-page', 'some/path')).toBe('https://example.com/sub-page/some/path');
|
|
118
118
|
|
|
119
119
|
expect(mergeUrlAndPath('https://example.com', 'https://elsewhere.com/some-path')).toBe('https://elsewhere.com/some-path');
|
|
120
|
+
|
|
121
|
+
// Protocol-relative URL
|
|
122
|
+
// For https://github.com/RealFaviconGenerator/core/issues/2
|
|
123
|
+
expect(mergeUrlAndPath('https://example.com', '//elsewhere.com/some-path')).toBe('https://elsewhere.com/some-path');
|
|
124
|
+
expect(mergeUrlAndPath('http://example.com', '//elsewhere.com/some-other/path')).toBe('http://elsewhere.com/some-other/path');
|
|
120
125
|
})
|
|
121
126
|
|
|
122
127
|
test('parseSizesAttribute', () => {
|
package/src/helper.ts
CHANGED
|
@@ -156,8 +156,11 @@ export const mergeUrlAndPath = (baseUrl: string, absoluteOrRelativePath: string)
|
|
|
156
156
|
|
|
157
157
|
const url = new URL(baseUrl);
|
|
158
158
|
|
|
159
|
-
//
|
|
160
|
-
if (absoluteOrRelativePath.startsWith('
|
|
159
|
+
// Protocol-relative URL
|
|
160
|
+
if (absoluteOrRelativePath.startsWith('//')) {
|
|
161
|
+
return `${url.protocol}${absoluteOrRelativePath}`;
|
|
162
|
+
} else if (absoluteOrRelativePath.startsWith('/')) {
|
|
163
|
+
// If the path starts with a slash, replace the pathname
|
|
161
164
|
return `${url.origin}${absoluteOrRelativePath}`;
|
|
162
165
|
} else {
|
|
163
166
|
// Otherwise, append the path to the existing pathname
|
package/src/types.ts
CHANGED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 RealFaviconGenerator
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|