Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 222a333

Browse files
authored
🐛 Fix 2 issues with custom html files in export
1. While exporting, if a route such as `[slug].html.js` is made that serves it's own html pages(with correct Content-Type header), those pages url's were being rewritten even though they were valid. Example: `simple.html` was being rewritten to `simple.html/index.html`. We now check for a `.html` on the end of the path before adding a `/index.html` to the end 2. When parsing exported html, the `<base>` element was checked for in the head of the doc. If this element didn't exist(for example if you generate your own html and miss adding this element) the error message is not clear what is wrong and is hard to track down. This change should avoid that confusion and use a sane default if not available.
1 parent 31d6f05 commit 222a333

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/api/export.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ async function _export({
112112
const is_html = type === 'text/html';
113113

114114
if (is_html) {
115-
if (pathname !== '/service-worker-index.html') {
115+
if (pathname !== '/service-worker-index.html'
116+
&& pathname.substr(pathname.length - 5) !== '.html')) {
116117
file = file === '' ? 'index.html' : `${file}/index.html`;
117118
}
118119
body = minify_html(body);
@@ -186,7 +187,7 @@ async function _export({
186187
const cleaned = clean_html(body);
187188

188189
const base_match = /<base ([\s\S]+?)>/m.exec(cleaned);
189-
const base_href = base_match && get_href(base_match[1]);
190+
base_match ? get_href(base_match[1]) : '/'
190191
const base = resolve(url.href, base_href);
191192

192193
let match;

0 commit comments

Comments
 (0)