Browse Source

fix: encode url if not encoded

pull/9772/head
Pranav C 3 weeks ago
parent
commit
52cf3ab244
  1. 11
      packages/nc-gui/components/virtual-cell/Button.vue

11
packages/nc-gui/components/virtual-cell/Button.vue

@ -1,6 +1,7 @@
<script setup lang="ts">
import type { ButtonType, ColumnType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { decode, encode } from 'html-entities'
const column = inject(ColumnInj) as Ref<
ColumnType & {
@ -50,7 +51,15 @@ const triggerAction = async () => {
const componentProps = computed(() => {
if (column.value.colOptions.type === 'url') {
let url = `${cellValue.value?.url}`
url = encodeURI(/^(https?|ftp|mailto|file):\/\//.test(url) ? url : url.trim() ? `http://${url}` : '')
url = /^(https?|ftp|mailto|file):\/\//.test(url) ? url : url.trim() ? `http://${url}` : ''
// if url params not encoded, encode them using encodeURI
try {
url = decodeURI(url) === url ? encodeURI(url) : url
} catch {
url = encodeURI(url)
}
return {
href: url,
target: '_blank',

Loading…
Cancel
Save