Skip to content

Commit ec4ad0a

Browse files
committed
fix: update html-minifier to be html-minifier-terser to solve vulnerability
1 parent f133623 commit ec4ad0a

File tree

6 files changed

+133
-66
lines changed

6 files changed

+133
-66
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"compression": "^1.7.4",
2929
"dotenv": "^16.0.0",
3030
"express": "^4.17.1",
31-
"html-minifier": "^4.0.0",
31+
"html-minifier-terser": "^7.2.0",
3232
"lighthouse": "^9.6.3",
3333
"puppeteer": "^24.8.2"
3434
},

src/format.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import chalk from 'chalk';
2-
import { minify } from 'html-minifier';
2+
import { minify } from 'html-minifier-terser';
33

44
import makeReplacements from './replacements.js';
55

@@ -40,7 +40,7 @@ export const formatShortSummary = (categories) => {
4040
.join(', ');
4141
};
4242

43-
export const formatResults = ({ results, thresholds }) => {
43+
export const formatResults = async ({ results, thresholds }) => {
4444
const runtimeError = results.lhr.runtimeError;
4545

4646
const categories = Object.values(results.lhr.categories).map(
@@ -71,7 +71,7 @@ export const formatResults = ({ results, thresholds }) => {
7171
const installable = results.lhr.audits['installable-manifest']?.score === 1;
7272
const details = { installable, formFactor, locale };
7373

74-
const report = minify(formattedReport, {
74+
const report = await minify(formattedReport, {
7575
removeAttributeQuotes: true,
7676
collapseWhitespace: true,
7777
removeRedundantAttributes: true,

src/format.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ describe('format', () => {
140140
report: '<!doctype html>\n' + '<html lang="en">Hi</html>\n',
141141
});
142142

143-
it('should return formatted results', () => {
144-
expect(formatResults({ results: getResults(), thresholds: {} })).toEqual({
143+
it('should return formatted results', async () => {
144+
expect(await formatResults({ results: getResults(), thresholds: {} })).toEqual({
145145
details: {
146146
formFactor: undefined,
147147
installable: false,
@@ -154,11 +154,11 @@ describe('format', () => {
154154
});
155155
});
156156

157-
it('should return formatted results with passing thresholds', () => {
157+
it('should return formatted results with passing thresholds', async () => {
158158
const thresholds = {
159159
performance: 0.1,
160160
};
161-
const formattedResults = formatResults({
161+
const formattedResults = await formatResults({
162162
results: getResults(),
163163
thresholds,
164164
});
@@ -173,11 +173,11 @@ describe('format', () => {
173173
]);
174174
});
175175

176-
it('should return formatted results with failing thresholds', () => {
176+
it('should return formatted results with failing thresholds', async () => {
177177
const thresholds = {
178178
performance: 1,
179179
};
180-
const formattedResults = formatResults({
180+
const formattedResults = await formatResults({
181181
results: getResults(),
182182
thresholds,
183183
});
@@ -197,7 +197,7 @@ describe('format', () => {
197197
]);
198198
});
199199

200-
it('should use supplied config settings and data to populate `details`', () => {
200+
it('should use supplied config settings and data to populate `details`', async () => {
201201
const results = getResults();
202202
results.lhr.configSettings = {
203203
locale: 'es',
@@ -208,7 +208,7 @@ describe('format', () => {
208208
score: 1,
209209
};
210210

211-
const formattedResults = formatResults({ results, thresholds: {} });
211+
const formattedResults = await formatResults({ results, thresholds: {} });
212212
expect(formattedResults.details).toEqual({
213213
formFactor: 'desktop',
214214
installable: true,

src/lib/run-audit-with-server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const runAuditWithServer = async ({
3636
return { error };
3737
} else {
3838
const { summary, shortSummary, details, report, errors, runtimeError } =
39-
formatResults({
39+
await formatResults({
4040
results,
4141
thresholds,
4242
});

src/lib/run-audit-with-url/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const runAuditWithUrl = async ({ path = '', url, thresholds, settings }) => {
2222
return { error };
2323
} else {
2424
const { summary, shortSummary, details, report, errors, runtimeError } =
25-
formatResults({
25+
await formatResults({
2626
results,
2727
thresholds,
2828
});

0 commit comments

Comments
 (0)