Skip to content

Commit

Permalink
Show filename if URL is invalid (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
GovernmentPlates authored Aug 28, 2024
1 parent fdc1d30 commit 5e3d4cc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pages/participant/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,20 @@ export function getAccompanyingPersons(sections: Section[]) {

function PictureField({title, description, data}: FieldProps) {
if (!data) {
return;
return null;
}

// fallback to showing the filename only if it's not a valid URL
const isValidUrl = data.startsWith('http://') || data.startsWith('https://');
if (!isValidUrl) {
return (
<div>
<FieldHeader title={title} description={description} />
<Typography variant="body1">{data}</Typography>
</div>
);
}

return (
<div>
<FieldHeader title={title} description={description} />
Expand Down

0 comments on commit 5e3d4cc

Please sign in to comment.