diff --git a/aio/src/app/shared/toc.service.spec.ts b/aio/src/app/shared/toc.service.spec.ts index f4962d9086f17..d623e2dacdafb 100644 --- a/aio/src/app/shared/toc.service.spec.ts +++ b/aio/src/app/shared/toc.service.spec.ts @@ -305,6 +305,10 @@ describe('TocService', () => { + `, docId); @@ -319,7 +323,7 @@ describe('TocService', () => { expect(tocItem.title).toEqual('Setup to develop locally.'); }); - it('should have removed anchor link from tocItem html content', () => { + it('should have removed anchor link and GitHub links from tocItem html content', () => { expect((tocItem.content as TestSafeHtml) .changingThisBreaksApplicationSecurity) .toEqual('Setup to develop locally.'); diff --git a/aio/src/app/shared/toc.service.ts b/aio/src/app/shared/toc.service.ts index fcbcdff11a630..0518d4768f6d8 100644 --- a/aio/src/app/shared/toc.service.ts +++ b/aio/src/app/shared/toc.service.ts @@ -57,15 +57,15 @@ export class TocService { } // Transform the HTML content to be safe to use in the ToC: - // - Strip off the auto-generated heading anchor links). + // - Strip off certain auto-generated elements (such as GitHub links and heading anchor links). // - Strip off any anchor links (but keep their content) // - Mark the HTML as trusted to be used with `[innerHTML]`. private extractHeadingSafeHtml(heading: HTMLHeadingElement) { const div: HTMLDivElement = this.document.createElement('div'); div.innerHTML = heading.innerHTML; - // Remove any `.header-link` elements (along with their content). - div.querySelectorAll('.header-link').forEach(removeNode); + // Remove any `.github-links` or `.header-link` elements (along with their content). + div.querySelectorAll('.github-links, .header-link').forEach(removeNode); // Remove any remaining `a` elements (but keep their content). div.querySelectorAll('a').forEach(anchorLink => {