Skip to content

Commit 5c488ea

Browse files
committed
Validate setter profile URL
1 parent b9beaf9 commit 5c488ea

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Diff for: dotcom-rendering/src/components/ArticleMeta.web.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export const ArticleMeta = ({
401401
{crossword?.creator && (
402402
<CrosswordSetter
403403
setter={crossword.creator.name}
404-
profile={crossword.creator.webUrl}
404+
profileUrl={crossword.creator.webUrl}
405405
/>
406406
)}
407407

Diff for: dotcom-rendering/src/components/CrosswordSetter.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,26 @@ const setterStyles = css`
1717
}
1818
`;
1919

20+
const isValidProfileUrl = (url: string): boolean => {
21+
return url.startsWith('https://www.theguardian.com/profile/');
22+
};
23+
2024
type Props = {
2125
setter: string;
22-
profile: string;
26+
profileUrl: string;
2327
};
2428

25-
export const CrosswordSetter = ({ setter, profile }: Props) => (
29+
export const CrosswordSetter = ({ setter, profileUrl }: Props) => (
2630
<address
2731
css={setterStyles}
2832
data-component="meta-byline"
2933
data-link-name="byline"
3034
>
31-
Set by: <a href={profile}>{setter}</a>
35+
Set by:{' '}
36+
{isValidProfileUrl(profileUrl) ? (
37+
<a href={profileUrl}>{setter}</a>
38+
) : (
39+
setter
40+
)}
3241
</address>
3342
);

0 commit comments

Comments
 (0)