Skip to content

Commit

Permalink
fix: trim url string value
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavxc committed Apr 3, 2024
1 parent c7b4cd0 commit a367f5d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/nc-gui/components/cell/Url.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,30 @@ const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!
const isForm = inject(IsFormInj)!
const trimVal = (val:string) => val && (val + '').trim();
// Used in the logic of when to display error since we are not storing the url if it's not valid
const localState = ref(value)
const vModel = computed({
get: () => value,
set: (val) => {
localState.value = val
if (!parseProp(column.value.meta)?.validate || (val && isValidURL(val)) || !val || isForm.value) {
if (!parseProp(column.value.meta)?.validate || (val && isValidURL(trimVal(val))) || !val || isForm.value) {
emit('update:modelValue', val)
}
},
})
const isValid = computed(() => value && isValidURL(value))
const isValid = computed(() => value && isValidURL(trimVal(value)))
const url = computed(() => {
if (!value || !isValidURL(value)) return ''
if (!value || !isValidURL(trimVal(value))) return ''
/** add url scheme if missing */
if (/^https?:\/\//.test(value)) return value
if (/^https?:\/\//.test(trimVal(value))) return trimVal(value)
return `https://${value}`
return `https://${trimVal(value)}`
})
const { cellUrlOptions } = useCellUrlConfig(url)
Expand All @@ -84,7 +86,7 @@ watch(
parseProp(column.value.meta)?.validate &&
!editEnabled.value &&
localState.value &&
!isValidURL(localState.value)
!isValidURL(trimVal(localState.value))
) {
message.error(t('msg.error.invalidURL'))
localState.value = undefined
Expand Down

1 comment on commit a367f5d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR changes have been deployed. Please run the following command to verify:

docker run -d -p 8888:8080 nocodb/nocodb-timely:0.204.9-pr-8178-20240404-0857

Please sign in to comment.