From bd043db35d33b21e8259ec2fd61e1c15394807b2 Mon Sep 17 00:00:00 2001 From: Anchen Date: Thu, 29 Jun 2017 17:08:52 +1000 Subject: [PATCH] Change headReg and bodyReg to allow spaces (#709) * change headReg and bodyReg to allow spaces * change regex to only allow space before closing tag --- index.js | 4 ++-- spec/BasicSpec.js | 28 ++++++++++++++++++++++++++++ spec/fixtures/spaced_plain.html | 7 +++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/spaced_plain.html diff --git a/index.js b/index.js index ad1710b..4e0bfe8 100644 --- a/index.js +++ b/index.js @@ -521,8 +521,8 @@ HtmlWebpackPlugin.prototype.generateAssetTags = function (assets) { */ HtmlWebpackPlugin.prototype.injectAssetsIntoHtml = function (html, assets, assetTags) { var htmlRegExp = /(]*>)/i; - var headRegExp = /(<\/head>)/i; - var bodyRegExp = /(<\/body>)/i; + var headRegExp = /(<\/head\s*>)/i; + var bodyRegExp = /(<\/body\s*>)/i; var body = assetTags.body.map(this.createHtmlTag); var head = assetTags.head.map(this.createHtmlTag); diff --git a/spec/BasicSpec.js b/spec/BasicSpec.js index 27ea085..facf354 100644 --- a/spec/BasicSpec.js +++ b/spec/BasicSpec.js @@ -1513,4 +1513,32 @@ describe('HtmlWebpackPlugin', function () { }, [/^