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

Commit

Permalink
Merge pull request #603 from sveltejs/gh-602
Browse files Browse the repository at this point in the history
fix handling of empty hrefs during export
  • Loading branch information
Rich-Harris authored Apr 27, 2019
2 parents 4f9919e + 6d5aa9a commit 90ec61f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/api/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@ async function _export({
}

function get_href(attrs: string) {
const match = /href\s*=\s*(?:"(.*?)"|'(.+?)'|([^\s>]+))/.exec(attrs);
return match[1] || match[2] || match[3];
const match = /href\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs);
return match && (match[1] || match[2] || match[3]);
}
7 changes: 6 additions & 1 deletion test/apps/export/src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<h1>Great success!</h1>

<a href="blog">blog</a>
<a href="">empty anchor</a>
<a href="">empty anchor</a>
<a href=''>empty anchor #2</a>
<a href=>empty anchor #3</a>
<a href= >empty anchor #4</a>
<a href>empty anchor #5</a>
<a>empty anchor #6</a>

0 comments on commit 90ec61f

Please sign in to comment.