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

Sane default for no base element in an html file #1208

Merged
merged 5 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ async function _export({
const cleaned = clean_html(body);

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

let match;
Expand Down
1 change: 1 addition & 0 deletions test/apps/export/src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<a href>empty anchor #5</a>
<a>empty anchor #6</a>
<a href="boom">boom</a>
<a href="test.html">html file</a>
<a href="test.pdf">pdf file</a>
13 changes: 13 additions & 0 deletions test/apps/export/static/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>

<head>
<title>Page Title</title>
</head>

<body>
<h1>Test Heading</h1>
<p>Test Paragraph.</p>
</body>

</html>
1 change: 1 addition & 0 deletions test/apps/export/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('export', function() {
'index.html',
'service-worker-index.html',
'service-worker.js',
'test.html',
'test.pdf',
...boom
].sort());
Expand Down