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

Commit 6d5aa9a

Browse files
committed
fix handling of empty hrefs during export (#602)
1 parent 7be7e1e commit 6d5aa9a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/api/export.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,6 @@ async function _export({
212212
}
213213

214214
function get_href(attrs: string) {
215-
const match = /href\s*=\s*(?:"(.*?)"|'(.+?)'|([^\s>]+))/.exec(attrs);
216-
return match[1] || match[2] || match[3];
215+
const match = /href\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs);
216+
return match && (match[1] || match[2] || match[3]);
217217
}
+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<h1>Great success!</h1>
22

33
<a href="blog">blog</a>
4-
<a href="">empty anchor</a>
4+
<a href="">empty anchor</a>
5+
<a href=''>empty anchor #2</a>
6+
<a href=>empty anchor #3</a>
7+
<a href= >empty anchor #4</a>
8+
<a href>empty anchor #5</a>
9+
<a>empty anchor #6</a>

0 commit comments

Comments
 (0)