Skip to content

Commit

Permalink
Validate setter profile URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmockett committed Jan 30, 2025
1 parent b9beaf9 commit acb38d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dotcom-rendering/src/components/ArticleMeta.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export const ArticleMeta = ({
{crossword?.creator && (
<CrosswordSetter
setter={crossword.creator.name}
profile={crossword.creator.webUrl}
profileUrl={crossword.creator.webUrl}
/>
)}

Expand Down
11 changes: 8 additions & 3 deletions dotcom-rendering/src/components/CrosswordSetter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ const setterStyles = css`
}
`;

const isValidProfileUrl = (url: string): boolean => {
return url.startsWith('https://www.theguardian.com/profile/');
};

type Props = {
setter: string;
profile: string;
profileUrl: string;
};

export const CrosswordSetter = ({ setter, profile }: Props) => (
export const CrosswordSetter = ({ setter, profileUrl: profile }: Props) => (
<address
css={setterStyles}
data-component="meta-byline"
data-link-name="byline"
>
Set by: <a href={profile}>{setter}</a>
Set by:{' '}
{isValidProfileUrl(profile) ? <a href={profile}>{setter}</a> : setter}
</address>
);

0 comments on commit acb38d0

Please sign in to comment.