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

Commit ab2e256

Browse files
jamesjnadeauthgh
andauthored
Allow export to succeed when user has not provided base tag (#1208)
Co-authored-by: Thomas Ghysels <[email protected]>
1 parent 993c541 commit ab2e256

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/api/export.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async function _export({
237237
const cleaned = clean_html(body as string);
238238

239239
const base_match = /<base ([\s\S]+?)>/m.exec(cleaned);
240-
const base_href = base_match && get_href(base_match[1]);
240+
const base_href = base_match ? get_href(base_match[1]) : path.dirname(url.pathname);
241241
const base = resolve(url.href, base_href);
242242

243243
let match;

test/apps/export/src/routes/index.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
<!-- svelte-ignore a11y-missing-attribute -->
1818
<a>empty anchor #6</a>
1919
<a href="boom">boom</a>
20+
<a href="test.html">html file</a>
2021
<a href="test.pdf">pdf file</a>

test/apps/export/static/test.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Page Title</title>
6+
</head>
7+
8+
<body>
9+
<h1>Test Heading</h1>
10+
<p>Test Paragraph.</p>
11+
</body>
12+
13+
</html>

test/apps/export/test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('export', function() {
4141
'index.html',
4242
'service-worker-index.html',
4343
'service-worker.js',
44+
'test.html',
4445
'test.pdf',
4546
'img/example-192.png',
4647
'img/example-512.png',

0 commit comments

Comments
 (0)