From be39f5ec685dd3d2c0bdbfe5fc370f99c472101a Mon Sep 17 00:00:00 2001 From: Omer Zak Date: Thu, 31 Dec 2020 04:27:05 +0200 Subject: [PATCH 1/2] Inline favicon sources with rel="shortcut icon" + unit test. --- lib/parse.js | 6 +++--- test/6a-inline-link-test.js | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 test/6a-inline-link-test.js diff --git a/lib/parse.js b/lib/parse.js index aae014d..b1f4ae4 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -10,7 +10,7 @@ const { isIgnored, isRemoteFilepath, parseAttributes, - parseProps, + parseProps } = require('./utils'); const htmlparser = require('htmlparser2'); const path = require('path'); @@ -48,7 +48,7 @@ module.exports = async function parse(context) { (tag === 'link' && attributes.rel && attributes.rel !== 'stylesheet' && - attributes.rel !== 'icon') + !attributes.rel.includes('icon')) ) { return; } @@ -85,7 +85,7 @@ module.exports = async function parse(context) { svgAsImage: 'svgasimage' in props ? props.svgasimage : context.svgAsImage, tag: match[1], - type, + type }); } } diff --git a/test/6a-inline-link-test.js b/test/6a-inline-link-test.js new file mode 100644 index 0000000..4cffa5b --- /dev/null +++ b/test/6a-inline-link-test.js @@ -0,0 +1,26 @@ +'use strict'; + +const { expect } = require('chai'); +const { inlineSource: inline } = require('..'); + +describe('inline ', () => { + before(function() { + process.chdir(require('path').resolve(__dirname, './fixtures')); + }); + + it('should inline favicon sources with rel="icon" [DUPLICATE from 6-inline-link-test]', async () => { + const test = ''; + const html = await inline(test, { compress: true }); + expect(html).to.eql( + '' + ); + }); + it('should inline favicon sources with rel="shortcut icon"', async () => { + const test = + ''; + const html = await inline(test, { compress: true }); + expect(html).to.eql( + '' + ); + }); +}); From 6da33389ea16a6237d5ac4c5b35633e2864e641e Mon Sep 17 00:00:00 2001 From: Omer Zak Date: Thu, 31 Dec 2020 05:02:16 +0200 Subject: [PATCH 2/2] Change test name. --- test/6a-inline-link-test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/6a-inline-link-test.js b/test/6a-inline-link-test.js index 4cffa5b..e53fe16 100644 --- a/test/6a-inline-link-test.js +++ b/test/6a-inline-link-test.js @@ -7,8 +7,7 @@ describe('inline ', () => { before(function() { process.chdir(require('path').resolve(__dirname, './fixtures')); }); - - it('should inline favicon sources with rel="icon" [DUPLICATE from 6-inline-link-test]', async () => { + it('should inline PNG favicon sources with rel="icon" [DUPLICATE from 6-inline-link-test]', async () => { const test = ''; const html = await inline(test, { compress: true }); expect(html).to.eql(