Skip to content

Commit

Permalink
chore(@dpc-sdp/ripple-tide-api): rename function to getPlainText
Browse files Browse the repository at this point in the history
  • Loading branch information
lambry committed Oct 21, 2024
1 parent e2e003e commit af6d095
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/nuxt-ripple/mapping/site/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getMediaPath,
getLinkFromField,
getSiteKeyValues,
stripNewLines,
getPlainText,
TideSiteApi
} from '@dpc-sdp/ripple-tide-api'
import {
Expand Down Expand Up @@ -55,7 +55,7 @@ export default {
: '<p>If you need a response, please use our <a href="/contact-us" class="rpl-text-link rpl-u-focusable-inline">contact us form</a>.</p>'
},
acknowledgementFooter: (src: any) => {
return stripNewLines(src?.field_acknowledgement_to_country)
return getPlainText(src?.field_acknowledgement_to_country)
},
copyrightHtml: (src: any) => {
return getBody(src.field_site_footer_text?.processed)
Expand Down
4 changes: 2 additions & 2 deletions packages/ripple-tide-api/src/utils/mapping-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getSiteKeyValues,
getSiteSection,
humanizeFilesize,
stripNewLines
getPlainText
} from './mapping-utils.js'

const field = {
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('ripple-tide-api/mapping utils', () => {
})

it(`returns a single line of text without line breaks`, () => {
expect(stripNewLines(field.field_acknowledgement_to_country)).toEqual(
expect(getPlainText(field.field_acknowledgement_to_country)).toEqual(
'We acknowledge Aboriginal and Torres Strait Islander people as the First People and traditional owners and custodians of the lands, seas and waters of Australia. We pay our respect to Elders past and present.'
)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/ripple-tide-api/src/utils/mapping-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export const getSiteSection = (sectionId: string, src: any) => {
/**
* @description strips line returns i.e. new line from the supplied content, returning a 'single' line
*/
export const stripNewLines = (content: string): string => {
export const getPlainText = (content: string): string => {
return content?.replace(/(\r\n|\n|\r)/g, '')?.trim()
}

Expand All @@ -263,5 +263,5 @@ export default {
getDocumentFromField,
getSiteKeyValues,
getSiteSection,
stripNewLines
getPlainText
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getCardImageFromField,
getImageFromField,
getLinkFromField,
stripNewLines
getPlainText
} from '@dpc-sdp/ripple-tide-api'

export interface ITideCardMeta {
Expand Down Expand Up @@ -59,7 +59,7 @@ const getCardSummary = (field: { [key: string]: any }) => {

const summary = linkedSummary ? linkedSummary : ownSummary

return stripNewLines(summary)
return getPlainText(summary)
}

const getCardImage = (field: {}): TideImageField => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getField,
getLinkFromField,
getImageFromField,
stripNewLines
getPlainText
} from '@dpc-sdp/ripple-tide-api'
import type { TideUrlField } from '@dpc-sdp/ripple-tide-api/types'
import { TideHeroHeader } from '@dpc-sdp/nuxt-ripple/types'
Expand All @@ -15,7 +15,7 @@ const getIntroText = (src) => {
src.field_page_intro_text ||
''

return stripNewLines(introText)
return getPlainText(introText)
}

const getHeaderTheme = (src) => {
Expand Down

0 comments on commit af6d095

Please sign in to comment.