Skip to content

Commit

Permalink
fix: auto-prefix https:// for incomplete URLs in source information…
Browse files Browse the repository at this point in the history
… field
  • Loading branch information
samshara committed Nov 26, 2024
1 parent 7cf2514 commit 766d98d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-flowers-greet.md
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions app/src/utils/importTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 766d98d

Please sign in to comment.