From 6c7ce5883a08944f35b3d8eb100342cd8a3c1b97 Mon Sep 17 00:00:00 2001 From: mikezimm <49648086+mikezimm@users.noreply.github.com> Date: Sat, 13 May 2023 01:15:48 -0400 Subject: [PATCH] Update GetAnchorUrl in SPService.ts Solve issue: https://github.com/pnp/sp-dev-fx-webparts/issues/3686 fix GetAnchorUrl so it creates correct anchorlink that has a + symbol in the heading. --- samples/react-page-navigator/src/Service/SPService.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/react-page-navigator/src/Service/SPService.ts b/samples/react-page-navigator/src/Service/SPService.ts index abe5bfcd0..42f2206e9 100644 --- a/samples/react-page-navigator/src/Service/SPService.ts +++ b/samples/react-page-navigator/src/Service/SPService.ts @@ -15,10 +15,11 @@ export class SPService { private static GetAnchorUrl(headingValue: string): string { let anchorUrl = `#${headingValue .toLowerCase() - .replace(/[{}|\[\]\<\>#@"'^%`?;:\/=~\\\s\s+]/g, " ") + .replace(/[{}|\[\]\<\>#@"'^%`?;:\/=~\\\s\s]/g, " ") .replace(/^(-|\s)*|(-|\s)*$/g, "") .replace(/\'|\?|\\|\/| |\&/g, "-") .replace(/-+/g, "-") + .replace(/[+]/g, "%2B") // https://github.com/pnp/sp-dev-fx-webparts/issues/3686 .substring(0, 128)}`; let counter = 1; @@ -110,4 +111,4 @@ export class SPService { return anchorLinks; } -} \ No newline at end of file +}