Skip to content

Commit

Permalink
24226 - Redirect external links (bcgov#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim authored Dec 16, 2024
1 parent ab84a09 commit d4e6499
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions auth-web/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Router from 'vue-router'
import { User } from '@/models/user'
import Vue from 'vue'
import { getRoutes } from './router'
import { handleExternalLinkRedirect } from '@/util/navigation'
import store from '@/stores/vuex'
import { useOrgStore } from '@/stores/org'
import { useUserStore } from '@/stores/user'
Expand Down Expand Up @@ -173,6 +174,10 @@ router.beforeEach(async (to, from, next) => {
return next({ path: `/${Pages.UPDATE_ACCOUNT}` })
}
}

if (handleExternalLinkRedirect(to.fullPath)) {
return
}
next()
}
})
Expand Down
9 changes: 9 additions & 0 deletions auth-web/src/util/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ export const goToFormPage = (entityType): void => {
export const goToSocieties = (): void => {
window.open(appendAccountId(ConfigHelper.getSocietiesUrl()), '_blank')
}

export const handleExternalLinkRedirect = (path: string): boolean => {
if (path.includes('/http')) {
const cleanPath = path.replace(/^\//, '')
window.location.href = cleanPath
return true
}
return false
}

0 comments on commit d4e6499

Please sign in to comment.