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

follow <link href> during export #1444

Merged
merged 1 commit into from
Aug 26, 2020
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
4 changes: 2 additions & 2 deletions src/api/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ async function _export({
const base = resolve(url.href, base_href);

let match;
const pattern = /<(a|img|source)\s+([\s\S]+?)>/gm;
const pattern = /<(a|img|link|source)\s+([\s\S]+?)>/gm;

while (match = pattern.exec(cleaned)) {
let hrefs: string[] = [];
const element = match[1];
const attrs = match[2];

if (element === 'a') {
if (element === 'a' || element === 'link') {
hrefs.push(get_href(attrs));
} else {
if (element === 'img') {
Expand Down
4 changes: 4 additions & 0 deletions test/apps/export/src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<svelte:head>
<link rel='manifest' href='manifest.json'>
</svelte:head>

<h1>Great success!</h1>

<a href="blog">blog</a>
Expand Down
4 changes: 4 additions & 0 deletions test/apps/export/src/routes/manifest.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function get(req, res) {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end('{}');
}
1 change: 1 addition & 0 deletions test/apps/export/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('export', function() {
'img/example-192.png',
'img/example-512.png',
'pdfs/test.pdf',
'manifest.json',
...boom
].sort());
});
Expand Down