Skip to content

Commit fcacad8

Browse files
committed
removing target when url doesn't have protocol (for example when pointing to an id)
1 parent c77f335 commit fcacad8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/utils/changelog/markdown.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ export function sanitizeRawHTML(
205205
if (resolvedHref && hasProtocol(resolvedHref, { acceptRelative: true })) {
206206
attribs.rel = 'nofollow noreferrer noopener'
207207
attribs.target = '_blank'
208+
} else {
209+
attribs.target = ''
208210
}
209211
attribs.href = resolvedHref
210212
return { tagName, attribs }
@@ -236,7 +238,7 @@ function resolveUrl(url: string, repoInfo: MarkdownRepoInfo, idPrefix: string) {
236238
return url
237239
}
238240
// Prefix anchor links to match heading IDs (avoids collision with page IDs)
239-
return `#${idPrefix}-${url.slice(1)}`
241+
return `#${idPrefix}-${slugify(url.slice(1))}`
240242
}
241243
if (hasProtocol(url, { acceptRelative: true })) {
242244
try {

0 commit comments

Comments
 (0)