html-webpack-plugin 4.0.3 → 4.0.4

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/index.js +26 -1
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [4.0.4](https://github.com/jantimon/html-webpack-plugin/compare/v4.0.3...v4.0.4) (2020-04-01)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * Fix querystring encoding ([#1386](https://github.com/jantimon/html-webpack-plugin/issues/1386)) ([4f48a39](https://github.com/jantimon/html-webpack-plugin/commit/4f48a39e5738a5d431be2bec39c1b1f0de800d57)), closes [#1355](https://github.com/jantimon/html-webpack-plugin/issues/1355)
11
+
12
+
13
+
5
14
  ## [4.0.3](https://github.com/jantimon/html-webpack-plugin/compare/v4.0.2...v4.0.3) (2020-03-28)
6
15
 
7
16
 
package/index.js CHANGED
@@ -939,10 +939,35 @@ class HtmlWebpackPlugin {
939
939
  * Encode each path component using `encodeURIComponent` as files can contain characters
940
940
  * which needs special encoding in URLs like `+ `.
941
941
  *
942
+ * Valid filesystem characters which need to be encoded for urls:
943
+ *
944
+ * # pound, % percent, & ampersand, { left curly bracket, } right curly bracket,
945
+ * \ back slash, < left angle bracket, > right angle bracket, * asterisk, ? question mark,
946
+ * blank spaces, $ dollar sign, ! exclamation point, ' single quotes, " double quotes,
947
+ * : colon, @ at sign, + plus sign, ` backtick, | pipe, = equal sign
948
+ *
949
+ * However the query string must not be encoded:
950
+ *
951
+ * fo:demonstration-path/very fancy+name.js?path=/home?value=abc&value=def#zzz
952
+ * ^ ^ ^ ^ ^ ^ ^ ^^ ^ ^ ^ ^ ^
953
+ * | | | | | | | || | | | | |
954
+ * encoded | | encoded | | || | | | | |
955
+ * ignored ignored ignored ignored ignored
956
+ *
942
957
  * @param {string} filePath
943
958
  */
944
959
  urlencodePath (filePath) {
945
- return filePath.split('/').map(encodeURIComponent).join('/');
960
+ // People use the filepath in quite unexpected ways.
961
+ // Try to extract the first querystring of the url:
962
+ //
963
+ // some+path/demo.html?value=abc?def
964
+ //
965
+ const queryStringStart = filePath.indexOf('?');
966
+ const urlPath = queryStringStart === -1 ? filePath : filePath.substr(0, queryStringStart);
967
+ const queryString = filePath.substr(urlPath.length);
968
+ // Encode all parts except '/' which are not part of the querystring:
969
+ const encodedUrlPath = urlPath.split('/').map(encodeURIComponent).join('/');
970
+ return encodedUrlPath + queryString;
946
971
  }
947
972
 
948
973
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "license": "MIT",
5
5
  "description": "Simplifies creation of HTML files to serve your webpack bundles",
6
6
  "author": "Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)",