@@ -22,6 +22,7 @@ describe("web-fetch-utils htmlToMarkdown entity decoding", () => {
2222 } ) ;
2323
2424 it ( "decodes & last so an escaped entity is not double-decoded" , ( ) => {
25+ // "'" is the correct HTML encoding of the literal text "'" and must survive intact.
2526 expect ( htmlToMarkdown ( `<p>Tom &#39;s pub</p>` ) . text ) . toBe ( "Tom 's pub" ) ;
2627 } ) ;
2728
@@ -30,8 +31,12 @@ describe("web-fetch-utils htmlToMarkdown entity decoding", () => {
3031 } ) ;
3132
3233 it ( "preserves the prior contract: uppercase named entities decode, malformed numeric stays literal" , ( ) => {
34+ // web_fetch historically matched named entities case-insensitively, so
35+ // uppercase forms must keep decoding rather than leaking through as text.
3336 expect ( htmlToMarkdown ( `<p>a & b</p>` ) . text ) . toBe ( "a & b" ) ;
3437 expect ( htmlToMarkdown ( `<p>x "y"</p>` ) . text ) . toBe ( 'x "y"' ) ;
38+ // A malformed numeric reference is not an entity and must survive as text,
39+ // not be consumed by a lenient parseInt (e.g. "'x;" must not become "'").
3540 expect ( htmlToMarkdown ( `<p>'x; end</p>` ) . text ) . toBe ( "'x; end" ) ;
3641 } ) ;
3742
@@ -43,9 +48,4 @@ describe("web-fetch-utils htmlToMarkdown entity decoding", () => {
4348 expect ( result . text ) . toBe ( prefix ) ;
4449 expect ( result . text ) . not . toContain ( String . fromCharCode ( 0xd83d ) ) ;
4550 } ) ;
46-
47- it ( "truncates extracted text without splitting surrogate pairs" , ( ) => {
48- expect ( truncateText ( "😀abc" , 1 ) ) . toEqual ( { text : "" , truncated : true } ) ;
49- expect ( truncateText ( "😀😀x" , 3 ) ) . toEqual ( { text : "😀" , truncated : true } ) ;
50- } ) ;
5151} ) ;
0 commit comments