Skip to content

Commit 548efc7

Browse files
committed
fix: invalid values for route.rewriteIndex option are treated as default value
1 parent d301f7d commit 548efc7

File tree

25 files changed

+292
-10
lines changed

25 files changed

+292
-10
lines changed

CHANGELOG.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
# Changelog
22

3+
## 4.20.2 (2025-04-17)
4+
5+
- fix: invalid values for `route.rewriteIndex` option are treated as default value
6+
37
## 4.20.1 (2025-04-17)
48

59
- fix: disallow `undefined` value for optional properties by `route` option
610

7-
## 4.20.0
11+
## 4.20.0 (2025-04-11)
812

913
- feat: add support for ESM data files
1014
- chore: remove tests with Node.js version 18
1115

12-
## 4.19.2
16+
## 4.19.2 (2025-04-01)
1317

1418
- feat: case-insensitive preprocessor patterns, #165
1519

16-
## 4.19.1
20+
## 4.19.1 (2025-03-29)
1721

1822
- fix: `js.chunkFilename` should default to `js.filename` when `js.filename` is specified as a string, #164
1923

20-
## 4.19.0
24+
## 4.19.0 (2025-03-16)
2125

2226
### 🔥 CHANGES by inlining SVG only
2327

@@ -46,7 +50,7 @@
4650
Result:
4751
```html
4852
<svg class="icon" ...>...</svg>
49-
```
53+
```
5054
- When inlining SVG as a data URL, consider Webpack's `generator.dataUrl()` and `generator.dataUrl.encoding` options.
5155
- Display a warning when used `?embed` URL query for SVG files in JS or CSS.
5256

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-bundler-webpack-plugin",
3-
"version": "4.20.1",
3+
"version": "4.20.2",
44
"description": "Generates complete single-page or multi-page website from source assets. Built-in support for Markdown, Eta, EJS, Handlebars, Nunjucks, Pug. Alternative to html-webpack-plugin.",
55
"keywords": [
66
"html",

src/Plugin/Option.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ class Option {
372372
if (typeof routerOptions === 'boolean') {
373373
this.router.enabled = routerOptions;
374374
} else if (typeof routerOptions === 'object') {
375+
// for invalid value, set default value
376+
if (routerOptions.rewriteIndex !== false && typeof routerOptions.rewriteIndex !== 'string') {
377+
routerOptions.rewriteIndex = this.router.rewriteIndex;
378+
}
379+
375380
this.router = { ...this.router, ...routerOptions };
376381

377382
if (typeof routerOptions.resolve !== 'function') {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
h1{color:green}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
h1{color:red}
1.74 KB
Loading
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Home</title>
5+
<link href="http://localhost:8080/assets/img/favicon.edda23bf.ico" rel="icon">
6+
7+
<!-- load page style -->
8+
<link href="http://localhost:8080/assets/css/style.fd838354.css" rel="stylesheet">
9+
</head>
10+
<body>
11+
<h1>Home</h1>
12+
<nav>
13+
<a href="http://localhost:8080/index.html">Home</a>
14+
| <a href="http://localhost:8080/index.html?q=1">Home (query)</a>
15+
| <a href="http://localhost:8080/index.html#test">Home (anchor)</a>
16+
| <a href="http://localhost:8080/login/signup/index.html">Sign up</a>
17+
| <a href="javascript:void 0" data-link="http://localhost:8080/page1.html" onclick="location.href=this.dataset.link">Page 1 (JS)</a>
18+
| <button href="http://localhost:8080/sub/page2.html" onclick="location.href=this.getAttribute('href')">Sub Page 2 (JS)</button>
19+
| <button data-hyperlink="http://localhost:8080/sub/page3.html" onclick="location.href=this.dataset.hyperlink">Sub Page 3 (JS)</button>
20+
| <a href="http://localhost:8080/assets/img/apple.02a7c382.png" target="_blank">Image file</a>
21+
| <a href="https://google.com" target="_blank">Google</a>
22+
| <a href="/index.html">Home (not resolvable)</a>
23+
</nav></body>
24+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Sign Up</title>
5+
<link href="http://localhost:8080/assets/img/favicon.edda23bf.ico" rel="icon">
6+
7+
<!-- load page style -->
8+
<link href="http://localhost:8080/assets/css/style.7fc9d183.css" rel="stylesheet">
9+
</head>
10+
<body>
11+
<h1>Sign Up</h1>
12+
<nav>
13+
<a href="http://localhost:8080/index.html">Home</a>
14+
| <a href="http://localhost:8080/index.html?q=1">Home (query)</a>
15+
| <a href="http://localhost:8080/index.html#test">Home (anchor)</a>
16+
| <a href="http://localhost:8080/login/signup/index.html">Sign up</a>
17+
| <a href="javascript:void 0" data-link="http://localhost:8080/page1.html" onclick="location.href=this.dataset.link">Page 1 (JS)</a>
18+
| <button href="http://localhost:8080/sub/page2.html" onclick="location.href=this.getAttribute('href')">Sub Page 2 (JS)</button>
19+
| <button data-hyperlink="http://localhost:8080/sub/page3.html" onclick="location.href=this.dataset.hyperlink">Sub Page 3 (JS)</button>
20+
| <a href="http://localhost:8080/assets/img/apple.02a7c382.png" target="_blank">Image file</a>
21+
| <a href="https://google.com" target="_blank">Google</a>
22+
| <a href="/index.html">Home (not resolvable)</a>
23+
</nav></body>
24+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Page 1</title>
5+
<link href="http://localhost:8080/assets/img/favicon.edda23bf.ico" rel="icon">
6+
</head>
7+
<body>
8+
<h1>Page 1</h1>
9+
<nav>
10+
<a href="http://localhost:8080/index.html">Home</a>
11+
</nav>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)