From 1013ff4a782e6c08b9ec52a6c1f37d3b3ef7d8b4 Mon Sep 17 00:00:00 2001
From: kieran-broomhall-nhs
<265510135+kieran-broomhall-nhs@users.noreply.github.com>
Date: Wed, 15 Apr 2026 09:23:05 +0100
Subject: [PATCH 1/3] VIA-647 AJ/TS RSV eligibility update for 1 April, 2026
---
.../eligibility/RSVEligibilityFallback.test.tsx | 4 ++--
.../_components/eligibility/RSVEligibilityFallback.tsx | 4 ++--
src/app/_components/nbs/PharmacyBookingInfo.test.tsx | 10 +++-------
src/app/_components/nbs/PharmacyBookingInfo.tsx | 2 +-
src/app/vaccines-for-all-ages/page.test.tsx | 7 ++++++-
src/models/ageBasedHub.test.tsx | 5 +++--
src/models/ageBasedHub.tsx | 1 +
src/models/vaccine.ts | 2 +-
8 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/app/_components/eligibility/RSVEligibilityFallback.test.tsx b/src/app/_components/eligibility/RSVEligibilityFallback.test.tsx
index ce25d84e..8986c2fe 100644
--- a/src/app/_components/eligibility/RSVEligibilityFallback.test.tsx
+++ b/src/app/_components/eligibility/RSVEligibilityFallback.test.tsx
@@ -24,8 +24,8 @@ describe("RSVEligibilityFallback", () => {
render(
Pharmacy booking test
), -})); - jest.mock("@src/app/_components/content/HowToGetVaccineFallback", () => ({ HowToGetVaccineFallback: jest .fn() @@ -32,32 +25,12 @@ describe("RSVEligibilityFallback", () => { expect(fallbackBulletPoint2).toBeVisible(); }); - it("should include Pharmacy booking info for specified vaccine", () => { - render(If you're aged 75 to 79 (or turned 80 after 1 September 2024) contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
"; + "Contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
"; const defaultConfig = configBuilder().withContentCachePath("wiremock/__files/").build(); Object.assign(mockedConfig, defaultConfig); diff --git a/src/services/content-api/content-service.ts b/src/services/content-api/content-service.ts index 80d1136c..46490c5a 100644 --- a/src/services/content-api/content-service.ts +++ b/src/services/content-api/content-service.ts @@ -30,7 +30,7 @@ const getContentForVaccine = async (vaccineType: VaccineType): Promisepara
para1
para2
para3
para4
", + text: "para
para1
para2
para3
para4
para5
para6
", name: "markdown", headline: "How To Get Headline", }; @@ -334,40 +338,80 @@ describe("ContentStylingService", () => { additionalInformation: mockAdditionalInformationSection, }; - it.each(Object.values(VaccineType))("should return styled content for %s", async () => { - const styledVaccineContent: StyledVaccineContent = await getStyledContentForVaccine(mockContent); - + const assertCommonStyledSections = ( + styledVaccineContent: StyledVaccineContent, + expectedHowToGetHeadline: string, + ) => { expect(styledVaccineContent).not.toBeNull(); expect(styledVaccineContent.overview).toEqual(mockContent.overview); expect(styledVaccineContent.whatVaccineIsFor?.heading).toEqual(mockWhatSection.headline); expect(styledVaccineContent.whoVaccineIsFor.heading).toEqual(mockWhoSection.headline); - expect(styledVaccineContent.howToGetVaccine.heading).toEqual(mockHowSection.headline); + expect(styledVaccineContent.howToGetVaccine.heading).toEqual(expectedHowToGetHeadline); expect(styledVaccineContent.vaccineSideEffects.heading).toEqual(mockSideEffectsSection.headline); expect(styledVaccineContent.extraDosesSchedule?.heading).toEqual(mockExtraDosesScheduleSection.headline); expect(styledVaccineContent.callout?.heading).toEqual(mockCallout.heading); expect(styledVaccineContent.recommendation?.heading).toEqual(mockRecommendation.heading); expect(styledVaccineContent.additionalInformation?.heading).toEqual(mockAdditionalInformationSection.headline); - const expectedGenericVaccineHowToGetSection = - "para
para1
para2
para3
para4
para
para1
para2
para3
para4
para5
para6
para1
para2
", + }; + const mockRsvCareHomeSubsection: VaccinePageSubsection = { + type: "simpleElement", + headline: "", + name: "markdown", + text: "para3
para4
", + }; + const mockRsvHowSection: VaccinePageSection = { + headline: "How to get this Vaccine", + subsections: [mockRsvOlderAdultsSubsection, mockRsvCareHomeSubsection], + }; + const mockRsvContent: VaccinePageContent = { ...mockContent, howToGetVaccine: mockRsvHowSection }; + + const styledVaccineContent = await getStyledContentForVaccine(mockRsvContent, VaccineType.RSV); + + assertCommonStyledSections(styledVaccineContent, mockRsvHowSection.headline); + + const expectedRsvHowToGetSection = + 'para1
para2
para3
para4
.*?<\/p>)+)/i; + + const subSection: VaccinePageSubsection = { + type: "simpleElement", + headline: "", + text: "
Intro.
Para one.
Para two.
Pregnancy para.
", + name: "markdown", + }; + + it("should return the heading and paragraphs when matching section header is found", () => { + const expectedExtractedHtml = "Para one.
Para two.
"; + + const extractedHtml = extractHtmlWithHeadingFromSubSectionByHeading(subSection, olderAdultsRegExp); + + expect(extractedHtml).toEqual(expectedExtractedHtml); + }); + + it("throws ContentParsingError if no heading matching section heading is found", () => { + const subSectionWithNoMatchingHeader: VaccinePageSubsection = { + ...subSection, + text: "Intro.
Pregnancy para.
", + }; + + expect(() => { + extractHtmlWithHeadingFromSubSectionByHeading(subSectionWithNoMatchingHeader, olderAdultsRegExp); + }).toThrow(ContentParsingError); + }); + + it("throws ContentParsingError if no paragraphs found for section heading", () => { + const subSectionWithNoParagraphs: VaccinePageSubsection = { + ...subSection, + text: "Intro.
Pregnancy para.
", + }; + + expect(() => { + extractHtmlWithHeadingFromSubSectionByHeading(subSectionWithNoParagraphs, olderAdultsRegExp); + }).toThrow(ContentParsingError); + }); + + it("throws ContentParsingError if type is not 'simpleElement'", () => { + const subSectionWithoutSimpleElement: VaccinePageSubsection = { + type: "tableElement", + name: "", + mainEntity: "", + }; + + expect(() => { + extractHtmlWithHeadingFromSubSectionByHeading(subSectionWithoutSimpleElement, olderAdultsRegExp); + }).toThrow(ContentParsingError); + }); + }); }); diff --git a/src/services/content-api/parsers/custom/extract-html.ts b/src/services/content-api/parsers/custom/extract-html.ts index de3ec06a..da1d981e 100644 --- a/src/services/content-api/parsers/custom/extract-html.ts +++ b/src/services/content-api/parsers/custom/extract-html.ts @@ -7,29 +7,46 @@ const log: Logger = logger.child({ module: "services-content-api-parsers-custom- const paragraphsRegExp: RegExp = /.*?<\/p>/g; -export const extractHtmlFromSubSectionByHeading = ( +const parseSubSectionMatches = ( subsection: VaccinePageSubsection, sectionHeadingRegEx: RegExp, -): string => { +): { fullMatch: string; capturedContent: string; paragraphs: string[] } => { if (subsection.type !== "simpleElement") { log.warn({ context: { type: subsection.type } }, "HowToGetSubsection element not found"); throw new ContentParsingError("HowToGetSubsection element not found"); } - const howToGetSectionMatches = sectionHeadingRegEx.exec(subsection.text); - if (!howToGetSectionMatches) { + const sectionMatches = sectionHeadingRegEx.exec(subsection.text); + if (!sectionMatches) { log.warn({ context: { text: subsection.text } }, "HowToGetSubsection header not found - has the content changed?"); throw new ContentParsingError("HowToGetSubsection header not found - has the content changed?"); } - const paragraphsMatches = howToGetSectionMatches[1].match(paragraphsRegExp); + const paragraphsMatches = sectionMatches[1].match(paragraphsRegExp); if (!paragraphsMatches) { log.warn( - { context: { text: howToGetSectionMatches[1] } }, + { context: { text: sectionMatches[1] } }, "HowToGetSubsection paragraph not found - has the content changed?", ); throw new ContentParsingError("HowToGetSubsection paragraph not found - has the content changed?"); } - return paragraphsMatches.join(""); + return { fullMatch: sectionMatches[0], capturedContent: sectionMatches[1], paragraphs: paragraphsMatches }; +}; + +export const extractHtmlFromSubSectionByHeading = ( + subsection: VaccinePageSubsection, + sectionHeadingRegEx: RegExp, +): string => { + const { paragraphs } = parseSubSectionMatches(subsection, sectionHeadingRegEx); + return paragraphs.join(""); +}; + +export const extractHtmlWithHeadingFromSubSectionByHeading = ( + subsection: VaccinePageSubsection, + sectionHeadingRegEx: RegExp, +): string => { + const { fullMatch, capturedContent, paragraphs } = parseSubSectionMatches(subsection, sectionHeadingRegEx); + const headingHtml = fullMatch.slice(0, fullMatch.length - capturedContent.length); + return `${headingHtml}${paragraphs.join("")}`; }; diff --git a/src/services/content-api/parsers/custom/rsv-pregnancy.test.tsx b/src/services/content-api/parsers/custom/rsv-pregnancy.test.tsx index 1c9e97ee..b5dd9b69 100644 --- a/src/services/content-api/parsers/custom/rsv-pregnancy.test.tsx +++ b/src/services/content-api/parsers/custom/rsv-pregnancy.test.tsx @@ -8,7 +8,7 @@ jest.mock("@src/services/nbs/nbs-service", () => ({ buildNbsUrl: jest.fn() })); jest.mock("@src/services/content-api/parsers/custom/extract-html"); const expectedHowToGetUnFilteredText = - "
There are different ways to get the RSV vaccine.
You should be offered the RSV vaccine around the time of your 28-week antenatal appointment.
Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour.
Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine.
If you're aged 75 to 79 (or turned 80 after 1 September 2024) contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
"; + "There are different ways to get the RSV vaccine.
You should be offered the RSV vaccine around the time of your 28-week antenatal appointment.
Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour.
Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine.
Contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
Speak to a member of staff at your care home or your GP surgery about how to get the RSV vaccine.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
"; const expectedHowToGetFilteredText = "You should be offered the RSV vaccine around the time of your 28-week antenatal appointment.
Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour.
Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine.
"; const expectedRsvInPregnancyRegExp: RegExp = /.*?<\/p>)+)/i; diff --git a/src/services/content-api/parsers/custom/rsv.test.tsx b/src/services/content-api/parsers/custom/rsv.test.tsx index ac986cdd..b85a1e5f 100644 --- a/src/services/content-api/parsers/custom/rsv.test.tsx +++ b/src/services/content-api/parsers/custom/rsv.test.tsx @@ -1,4 +1,4 @@ -import { extractHtmlFromSubSectionByHeading } from "@src/services/content-api/parsers/custom/extract-html"; +import { extractHtmlWithHeadingFromSubSectionByHeading } from "@src/services/content-api/parsers/custom/extract-html"; import { buildFilteredContentForRSVOlderAdultsVaccine } from "@src/services/content-api/parsers/custom/rsv"; import { SimpleSubsection } from "@src/services/content-api/types"; import { genericVaccineContentAPIResponseWithRSVGettingAccess } from "@test-data/content-api/data-rsv"; @@ -8,17 +8,22 @@ jest.mock("@src/services/nbs/nbs-service", () => ({ buildNbsUrl: jest.fn() })); jest.mock("@src/services/content-api/parsers/custom/extract-html"); const expectedHowToGetOlderAdultsUnFilteredText = - "
There are different ways to get the RSV vaccine.
You should be offered the RSV vaccine around the time of your 28-week antenatal appointment.
Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour.
Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine.
If you're aged 75 to 79 (or turned 80 after 1 September 2024) contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
"; -const expectedHowToGetOlderAdultsFilteredText = - "If you're aged 75 to 79 (or turned 80 after 1 September 2024) contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
"; -const expectedOlderAdultsRegExp: RegExp = - /.*?<\/p>)+)/i; + "
There are different ways to get the RSV vaccine.
You should be offered the RSV vaccine around the time of your 28-week antenatal appointment.
Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour.
Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine.
Contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
Speak to a member of staff at your care home or your GP surgery about how to get the RSV vaccine.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
"; +const expectedOlderAdultsFilteredText = + "Contact your GP surgery to book your RSV vaccination.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
You do not need to wait to be contacted before booking your vaccination.
"; +const expectedOlderAdultsInCareHomeFilteredText = + "Speak to a member of staff at your care home or your GP surgery about how to get the RSV vaccine.
Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email.
"; +const expectedOlderAdultsRegExp: RegExp = /.*?<\/p>)+)/i; +const expectedOlderAdultsInCareHomeRegExp: RegExp = + /
.*?<\/p>)+)/i; const apiResponse = JSON.stringify(genericVaccineContentAPIResponseWithRSVGettingAccess); describe("buildFilteredContentForRSVOlderAdultsVaccine", () => { beforeEach(() => { - (extractHtmlFromSubSectionByHeading as jest.Mock).mockReturnValue(expectedHowToGetOlderAdultsFilteredText); + (extractHtmlWithHeadingFromSubSectionByHeading as jest.Mock) + .mockReturnValueOnce(expectedOlderAdultsFilteredText) + .mockReturnValueOnce(expectedOlderAdultsInCareHomeFilteredText); }); it("should return standard vaccine content for most fields", async () => { @@ -35,17 +40,25 @@ describe("buildFilteredContentForRSVOlderAdultsVaccine", () => { expect(pageCopyForRSVOlderAdultsVaccine.extraDosesSchedule).toBeUndefined(); }); - it("should return howToGet section with only text matching pregnancy regex", async () => { + it("should return howToGet section with two subsections for older adults and care home", async () => { const pageCopyForRSVOlderAdultsVaccine = await buildFilteredContentForRSVOlderAdultsVaccine(apiResponse); expect(pageCopyForRSVOlderAdultsVaccine.howToGetVaccine).toBeDefined(); - expect(pageCopyForRSVOlderAdultsVaccine.howToGetVaccine.subsections.length).toBe(1); - const howToGetSubsection: SimpleSubsection = pageCopyForRSVOlderAdultsVaccine.howToGetVaccine - .subsections[0] as SimpleSubsection; - expect(howToGetSubsection.text).toBe(expectedHowToGetOlderAdultsFilteredText); - expect(extractHtmlFromSubSectionByHeading).toHaveBeenCalledWith( + expect(pageCopyForRSVOlderAdultsVaccine.howToGetVaccine.subsections.length).toBe(2); + + const olderAdultsSubsection = pageCopyForRSVOlderAdultsVaccine.howToGetVaccine.subsections[0] as SimpleSubsection; + const careHomeSubsection = pageCopyForRSVOlderAdultsVaccine.howToGetVaccine.subsections[1] as SimpleSubsection; + + expect(olderAdultsSubsection.text).toBe(expectedOlderAdultsFilteredText); + expect(careHomeSubsection.text).toBe(expectedOlderAdultsInCareHomeFilteredText); + + expect(extractHtmlWithHeadingFromSubSectionByHeading).toHaveBeenCalledWith( expect.objectContaining({ text: expectedHowToGetOlderAdultsUnFilteredText }), expectedOlderAdultsRegExp, ); + expect(extractHtmlWithHeadingFromSubSectionByHeading).toHaveBeenCalledWith( + expect.objectContaining({ text: expectedHowToGetOlderAdultsUnFilteredText }), + expectedOlderAdultsInCareHomeRegExp, + ); }); }); diff --git a/src/services/content-api/parsers/custom/rsv.tsx b/src/services/content-api/parsers/custom/rsv.tsx index 471fb51c..99e60935 100644 --- a/src/services/content-api/parsers/custom/rsv.tsx +++ b/src/services/content-api/parsers/custom/rsv.tsx @@ -1,16 +1,15 @@ import { buildFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service"; -import { extractHtmlFromSubSectionByHeading } from "@src/services/content-api/parsers/custom/extract-html"; +import { extractHtmlWithHeadingFromSubSectionByHeading } from "@src/services/content-api/parsers/custom/extract-html"; import { VaccinePageContent, VaccinePageSection, VaccinePageSubsection } from "@src/services/content-api/types"; -const olderAdultsRegExp: RegExp = - /
.*?<\/p>)+)/i; +const olderAdultsRegExp: RegExp = /
.*?<\/p>)+)/i; +const olderAdultsInCareHomeRegExp: RegExp = + /
.*?<\/p>)+)/i;
export const buildFilteredContentForRSVOlderAdultsVaccine = async (apiContent: string): Promise There are different ways to get the RSV vaccine. You should be offered the RSV vaccine around the time of your 28-week antenatal appointment. Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour. Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine. If you're aged 75 to 79 (or turned 80 after 1 September 2024) contact your GP surgery to book your RSV vaccination. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. You do not need to wait to be contacted before booking your vaccination. There are different ways to get the RSV vaccine. You should be offered the RSV vaccine around the time of your 28-week antenatal appointment. Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour. Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine. Contact your GP surgery to book your RSV vaccination. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. You do not need to wait to be contacted before booking your vaccination. Speak to a member of staff at your care home or your GP surgery about how to get the RSV vaccine. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. There are different ways to get the RSV vaccine. You should be offered the RSV vaccine around the time of your 28-week antenatal appointment. Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour. Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine. If you're aged 75 to 79 (or turned 80 after 1 September 2024) contact your GP surgery to book your RSV vaccination. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. You do not need to wait to be contacted before booking your vaccination. There are different ways to get the RSV vaccine. You should be offered the RSV vaccine around the time of your 28-week antenatal appointment. Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour. Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine. Contact your GP surgery to book your RSV vaccination. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. You do not need to wait to be contacted before booking your vaccination. Speak to a member of staff at your care home or your GP surgery about how to get the RSV vaccine. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. There are different ways to get the RSV vaccine. You should be offered the RSV vaccine around the time of your 28-week antenatal appointment. Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour. Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine. If you're aged 75 to 79 (or turned 80 after 1 September 2024) contact your GP surgery to book your RSV vaccination. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. You do not need to wait to be contacted before booking your vaccination. There are different ways to get the RSV vaccine. You should be offered the RSV vaccine around the time of your 28-week antenatal appointment. Getting vaccinated as soon as possible from 28 weeks will provide the best protection for your baby. But the vaccine can be given later if needed, including up until you go into labour. Speak to your maternity service or GP surgery if you're 28 weeks pregnant or more and have not been offered the vaccine. Contact your GP surgery to book your RSV vaccination. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. You do not need to wait to be contacted before booking your vaccination. Speak to a member of staff at your care home or your GP surgery about how to get the RSV vaccine. Your GP surgery may contact you about getting the RSV vaccine. This may be by letter, text, phone call or email. .*?<\/p>/g;
const parseSubSectionMatches = (
subsection: VaccinePageSubsection,
sectionHeadingRegEx: RegExp,
-): { fullMatch: string; capturedContent: string; paragraphs: string[] } => {
+): { heading: string; paragraphs: string[] } => {
if (subsection.type !== "simpleElement") {
log.warn({ context: { type: subsection.type } }, "HowToGetSubsection element not found");
throw new ContentParsingError("HowToGetSubsection element not found");
@@ -22,16 +22,18 @@ const parseSubSectionMatches = (
throw new ContentParsingError("HowToGetSubsection header not found - has the content changed?");
}
- const paragraphsMatches = sectionMatches[1].match(paragraphsRegExp);
+ const [fullMatch, capturedContent] = sectionMatches;
+
+ const paragraphsMatches = capturedContent.match(paragraphsRegExp);
if (!paragraphsMatches) {
log.warn(
- { context: { text: sectionMatches[1] } },
+ { context: { text: capturedContent } },
"HowToGetSubsection paragraph not found - has the content changed?",
);
throw new ContentParsingError("HowToGetSubsection paragraph not found - has the content changed?");
}
-
- return { fullMatch: sectionMatches[0], capturedContent: sectionMatches[1], paragraphs: paragraphsMatches };
+ const heading = fullMatch.slice(0, -capturedContent.length);
+ return { heading, paragraphs: paragraphsMatches };
};
export const extractHtmlFromSubSectionByHeading = (
@@ -46,7 +48,6 @@ export const extractHtmlWithHeadingFromSubSectionByHeading = (
subsection: VaccinePageSubsection,
sectionHeadingRegEx: RegExp,
): string => {
- const { fullMatch, capturedContent, paragraphs } = parseSubSectionMatches(subsection, sectionHeadingRegEx);
- const headingHtml = fullMatch.slice(0, fullMatch.length - capturedContent.length);
- return `${headingHtml}${paragraphs.join("")}`;
+ const { heading, paragraphs } = parseSubSectionMatches(subsection, sectionHeadingRegEx);
+ return `${heading}${paragraphs.join("")}`;
};
If you're pregnant
If you're aged 75 to 79 (or turned 80 after 1 September 2024)
If you're pregnant
If you're aged 75 or over
If you live in a care home for older adults
If you're pregnant
If you're aged 75 to 79 (or turned 80 after 1 September 2024)
If you're pregnant
If you're aged 75 or over
If you live in a care home for older adults
If you're pregnant
If you're aged 75 to 79 (or turned 80 after 1 September 2024)
If you're pregnant
If you're aged 75 or over
If you live in a care home for older adults