Browse Source

Nc fix(nc-gui): form redirect url issue (#9612)

* fix(nc-gui): form redirect url issue

* fix(nc-gui): reload page after adding form redirect url in pushState
pull/9616/head
Ramesh Mane 2 months ago committed by GitHub
parent
commit
fe8e8b76cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      packages/nc-gui/composables/useSharedFormViewStore.ts

21
packages/nc-gui/composables/useSharedFormViewStore.ts

@ -395,9 +395,24 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
const pk = extractPkFromRow(newRecord, meta.value?.columns as ColumnType[])
if (pk && isValidRedirectUrl.value) {
const url = sharedFormView.value!.redirect_url!.replace('{record_id}', pk)
window.location.href = url
window.location.reload()
const redirectUrl = sharedFormView.value!.redirect_url!.replace('{record_id}', pk)
// Create an anchor element to parse the URL
const anchor = document.createElement('a')
anchor.href = redirectUrl
// Check if the redirect URL has the same host as the current page
const isSameHost = anchor.host === window.location.host
if (isSameHost) {
// Use pushState for internal links
window.history.pushState({}, 'Redirect', redirectUrl)
// Reload the page
window.location.reload()
} else {
// For external links, use window.location.href
window.location.href = redirectUrl
}
} else {
submitted.value = true
progress.value = false

Loading…
Cancel
Save