File tree Expand file tree Collapse file tree 4 files changed +31
-15
lines changed
Expand file tree Collapse file tree 4 files changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ title: Changelog
44
55## Unreleased
66
7+ ### Bug Fixes
8+
9+ - Fixed anchor link generation to members named ` $ ` , #3065 .
10+
711## v0.28.16 (2026-01-12)
812
913### Bug Fixes
Original file line number Diff line number Diff line change @@ -18,19 +18,24 @@ export class Slugger {
1818 // # test <t>
1919 // both of the above should slug to test-t
2020
21- return (
22- value
23- . trim ( )
24- // remove unwanted chars
25- . replace (
26- / [ \u2000 - \u206F \u2E00 - \u2E7F \\ ' ! " # $ % & ( ) * + , . / : ; < = > ? @ [ \] ^ ` { | } ~ ] / g,
27- "" ,
28- )
29- // change whitespace to dash
30- . replace ( / \s / g, "-" )
31- // combine adjacent dashes
32- . replace ( / - - + / , "-" )
33- ) ;
21+ const slug = value
22+ . trim ( )
23+ // remove unwanted chars
24+ . replace (
25+ / [ \u2000 - \u206F \u2E00 - \u2E7F \\ ' ! " # $ % & ( ) * + , . / : ; < = > ? @ [ \] ^ ` { | } ~ ] / g,
26+ "" ,
27+ )
28+ // change whitespace to dash
29+ . replace ( / \s / g, "-" )
30+ // combine adjacent dashes
31+ . replace ( / - - + / , "-" ) ;
32+
33+ // #3065 unfortunately some headers might result in a desired slug which is
34+ // completely empty. In that case, we still need to return *something* so that
35+ // we don't end up generating an empty anchor, which is invalid according to the
36+ // spec. GitHub's slugger rules don't handle this, so I've somewhat arbitrarily
37+ // chosen "_" here. If GitHub ever fixes that issue, this might need to be adjusted.
38+ return slug || "_" ;
3439 }
3540
3641 constructor ( private options : TypeDocOptionMap [ "sluggerConfiguration" ] ) { }
Original file line number Diff line number Diff line change @@ -125,8 +125,9 @@ export type TypeDocOptions = {
125125 TypeDocOptionMap [ K ] extends ManuallyValidatedOption <
126126 infer ManuallyValidated
127127 > ? ManuallyValidated :
128- TypeDocOptionMap [ K ] extends
129- NormalizedPath [ ] | NormalizedPathOrModule [ ] | NormalizedPathOrModuleOrFunction [ ] | GlobString [ ] ? string [ ] :
128+ TypeDocOptionMap [ K ] extends NormalizedPathOrModuleOrFunction [ ] ?
129+ Array < string | ( ( app : Application ) => Promise < void > | void ) > :
130+ TypeDocOptionMap [ K ] extends NormalizedPath [ ] | NormalizedPathOrModule [ ] | GlobString [ ] ? string [ ] :
130131 TypeDocOptionMap [ K ] extends NormalizedPath ? string :
131132 TypeDocOptionMap [ K ] extends
132133 | string
Original file line number Diff line number Diff line change @@ -24,4 +24,10 @@ describe("Slugger", () => {
2424 const slugger = new Slugger ( { lowercase : true } ) ;
2525 equal ( slugger . slug ( "test test2" ) , "test-test2" ) ;
2626 } ) ;
27+
28+ it ( "Handles empty slugs" , ( ) => {
29+ const slugger = new Slugger ( { lowercase : true } ) ;
30+ equal ( slugger . slug ( "$" ) , "_" ) ;
31+ equal ( slugger . slug ( "$" ) , "_-1" ) ;
32+ } ) ;
2733} ) ;
You can’t perform that action at this time.
0 commit comments