Skip to content

Commit 2ec90fa

Browse files
committed
fix: handle empty hash fragments while resolving URLs
1 parent 3fe683a commit 2ec90fa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

server/utils/readme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ function resolveUrl(url: string, packageName: string, repoInfo?: RepositoryInfo)
344344
// Normalize markdown-style heading fragments to the same slug format used
345345
// for generated README heading IDs, but leave already-prefixed values as-is.
346346
const fragment = url.slice(1)
347+
if (!fragment) {
348+
return '#'
349+
}
347350
if (fragment.startsWith(USER_CONTENT_PREFIX)) {
348351
return `#${fragment}`
349352
}

0 commit comments

Comments
 (0)