Skip to content

Commit 0056b60

Browse files
samsharafrozenhelium
authored andcommitted
fix: auto-prefix https:// for incomplete URLs in source information field
1 parent b0eae23 commit 0056b60

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.changeset/wise-flowers-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Auto append https:// for incomplete URLs in [#1505](https://github.com/IFRCGo/go-web-app/issues/1505)

app/src/utils/importTemplate.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,18 @@ export function getValueFromImportTemplate<
346346

347347
if (schema.type === 'input') {
348348
const value = formValues[fieldName];
349+
if (
350+
(fieldName === 'source_information__source__0__source_link'
351+
|| fieldName === 'source_information__source__1__source_link'
352+
|| fieldName === 'source_information__source__2__source_link'
353+
|| fieldName === 'source_information__source__3__source_link'
354+
|| fieldName === 'source_information__source__4__source_link'
355+
)
356+
&& isDefined(value) && (typeof value === 'string') && !value.includes('://')
357+
) {
358+
// TODO: we need to find a better solution to this
359+
return `https://${value}`;
360+
}
349361
// TODO: add validation from schema.validation
350362
return value;
351363
}

0 commit comments

Comments
 (0)