Skip to content

Commit

Permalink
refactor(nuxt-ripple): ♻️ respond on all 6 redirect codes, use naviga…
Browse files Browse the repository at this point in the history
…teTo
  • Loading branch information
waitingallday committed Jul 17, 2023
1 parent 97da41c commit fa89b2f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/nuxt-ripple/composables/use-tide-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,21 @@ export const useTidePage = async (
useTideError(error.value?.statusCode)
}

// 301 redirect
if (data.value.type === 'redirect' && data.value.status_code === '301') {
useRouter().replace(data.value.redirect_url)
// Redirect on the 6 codes that Drupal supplies
if (data.value.type === 'redirect') {
switch (data.value.status_code) {
case '301':
case '302':
case '303':
case '304':
case '305':
case '307':
await navigateTo(data.value.redirect_url, {
redirectCode: data.value.status_code
})
break
default:
}
}

return data.value
Expand Down

0 comments on commit fa89b2f

Please sign in to comment.