Skip to content

Commit

Permalink
Merge pull request #1245 from assemblee-virtuelle/fix-MultiUrlField
Browse files Browse the repository at this point in the history
[field-components] MultiUrlField - Handle not-url values correctly
  • Loading branch information
mguihal authored Jul 14, 2024
2 parents 8431d0e + bbbb176 commit d53d189
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
8 changes: 6 additions & 2 deletions src/frontend/packages/field-components/dist/index.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/frontend/packages/field-components/dist/index.d.ts.map
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mappings":";;;;;;ACGA;;;4CAaC;ACbD;;;4CAYC;AGVD;;;;;;4CA4BC;AC0CD;;;QA4BC;AC1FD,wFA0CC","sources":["packages/field-components/src/src/AvatarWithLabelField.js","packages/field-components/src/src/ReferenceArrayField.js","packages/field-components/src/src/ReferenceField.js","packages/field-components/src/src/QuickAppendReferenceArrayField/ResultsList.js","packages/field-components/src/src/QuickAppendReferenceArrayField/QuickAppendDialog.js","packages/field-components/src/src/QuickAppendReferenceArrayField/QuickAppendReferenceArrayField.js","packages/field-components/src/src/MultiUrlField.js","packages/field-components/src/src/SeparatedListField.js","packages/field-components/src/src/index.ts","packages/field-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"export { default as AvatarWithLabelField } from './AvatarWithLabelField';\nexport { default as ReferenceArrayField } from './ReferenceArrayField';\nexport { default as ReferenceField } from './ReferenceField';\nexport { default as QuickAppendReferenceArrayField } from './QuickAppendReferenceArrayField/QuickAppendReferenceArrayField';\nexport { default as MultiUrlField } from './MultiUrlField';\nexport { default as SeparatedListField } from './SeparatedListField';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
{"mappings":";;;;;;ACGA;;;4CAaC;ACbD;;;4CAYC;AGVD;;;;;;4CA4BC;AC0CD;;;QAkCC;AChGD,wFA0CC","sources":["packages/field-components/src/src/AvatarWithLabelField.js","packages/field-components/src/src/ReferenceArrayField.js","packages/field-components/src/src/ReferenceField.js","packages/field-components/src/src/QuickAppendReferenceArrayField/ResultsList.js","packages/field-components/src/src/QuickAppendReferenceArrayField/QuickAppendDialog.js","packages/field-components/src/src/QuickAppendReferenceArrayField/QuickAppendReferenceArrayField.js","packages/field-components/src/src/MultiUrlField.js","packages/field-components/src/src/SeparatedListField.js","packages/field-components/src/src/index.ts","packages/field-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"export { default as AvatarWithLabelField } from './AvatarWithLabelField';\nexport { default as ReferenceArrayField } from './ReferenceArrayField';\nexport { default as ReferenceField } from './ReferenceField';\nexport { default as QuickAppendReferenceArrayField } from './QuickAppendReferenceArrayField/QuickAppendReferenceArrayField';\nexport { default as MultiUrlField } from './MultiUrlField';\nexport { default as SeparatedListField } from './SeparatedListField';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
8 changes: 6 additions & 2 deletions src/frontend/packages/field-components/dist/index.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/frontend/packages/field-components/src/MultiUrlField.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ const MultiUrlField = ({ source, domainMapping }) => {
const urlArray = record[source] ? (Array.isArray(record[source]) ? record[source] : [record[source]]) : [];
return urlArray.map((url, index) => {
if (!url.startsWith('http')) url = `https://${url}`;
const parsedUrl = new URL(url);
if (!parsedUrl) return null;

let parsedUrl = null;
try {
parsedUrl = new URL(url);
} catch (e) {
return null;
}

const chip = newDomainMapping[parsedUrl.hostname] || {
label: 'Site web',
icon: <LanguageIcon />,
Expand Down

0 comments on commit d53d189

Please sign in to comment.