From 568282051e933e6f85e488168f7f3dacae5e8e14 Mon Sep 17 00:00:00 2001 From: Dominic Watson Date: Thu, 17 Oct 2019 12:08:21 +0200 Subject: [PATCH] feat(matchers): ignore scripts with nomodule --- posthtml-preload.js | 1 + test/preload.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/posthtml-preload.js b/posthtml-preload.js index ae36e5c..180013f 100644 --- a/posthtml-preload.js +++ b/posthtml-preload.js @@ -25,6 +25,7 @@ module.exports = function(options, foundEntries) { tag: 'script', attrs: { src: true, + nomodule: false, }, }); } diff --git a/test/preload.js b/test/preload.js index 115fc46..e64f725 100644 --- a/test/preload.js +++ b/test/preload.js @@ -121,7 +121,14 @@ describe('preload', function() { .expect(200, done); }); - it('should create Link header for mutliple scripts', function(done) { + it('should ignore nomodule scripts', function(done) { + request(this.server) + .get('/blog/nomodule-script') + .expect('Content-Type', 'text/html; charset=utf-8') + .expect(200, done); + }); + + it('should create Link header for multiple scripts', function(done) { request(this.server) .get('/blog/multi-script') .expect('Content-Type', 'text/html; charset=utf-8') @@ -425,6 +432,15 @@ function createServer(options) { }, }); + router.route('/blog/nomodule-script', { + GET: function(req, res) { + res.statusCode = 200; + res.setHeader('Content-Type', 'text/html; charset=utf-8'); + res.write(''); + res.end(); + }, + }); + router.route('/blog/multi-script', { GET: function(req, res) { res.statusCode = 200;