diff --git a/.changeset/wise-flowers-greet.md b/.changeset/wise-flowers-greet.md new file mode 100644 index 000000000..aebeb0826 --- /dev/null +++ b/.changeset/wise-flowers-greet.md @@ -0,0 +1,5 @@ +--- +"go-web-app": patch +--- + +Auto append https:// for incomplete URLs in [#1505](https://github.com/IFRCGo/go-web-app/issues/1505) diff --git a/app/src/utils/importTemplate.ts b/app/src/utils/importTemplate.ts index cd4820387..1c63e6c35 100644 --- a/app/src/utils/importTemplate.ts +++ b/app/src/utils/importTemplate.ts @@ -346,6 +346,18 @@ export function getValueFromImportTemplate< if (schema.type === 'input') { const value = formValues[fieldName]; + if ( + (fieldName === 'source_information__source__0__source_link' + || fieldName === 'source_information__source__1__source_link' + || fieldName === 'source_information__source__2__source_link' + || fieldName === 'source_information__source__3__source_link' + || fieldName === 'source_information__source__4__source_link' + ) + && isDefined(value) && (typeof value === 'string') && !value.includes('://') + ) { + // TODO: we need to find a better solution to this + return `https://${value}`; + } // TODO: add validation from schema.validation return value; }