Skip to content

Commit f3d1ee7

Browse files
committed
Fix handling of empty prefix autolink
1 parent e5ac0ae commit f3d1ee7

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/lib/hljs/utils.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function autolink(html, language) {
4646
if (status === 'prefix') {
4747
if (elem.className === 'hljs-symbol') {
4848
prefix = elem.textContent.replace(/:$/, '');
49-
} else if (prefix && elem.className === 'hljs-literal') {
49+
} else if (prefix !== null && elem.className === 'hljs-literal') {
5050
prefixes[prefix] = elem.textContent.replace(/^<|>$/g, '');
5151
elem.innerHTML = `&lt;<span href="${prefixes[prefix]}" title="${prefixes[prefix]}">${prefixes[prefix]}</span>&gt;`;
5252
prefix = null;
@@ -73,9 +73,7 @@ export function autolink(html, language) {
7373
}
7474
let localPart = elem.textContent.substring(colon + 1),
7575
url;
76-
if (colon === 0 && base) {
77-
url = base + localPart;
78-
} else if (colon > -1) {
76+
if (colon > -1) {
7977
const prefix = elem.textContent.substring(0, colon);
8078
if (prefixes[prefix]) {
8179
url = prefixes[prefix] + localPart;

0 commit comments

Comments
 (0)