MCPcopy
hub / github.com/ThatGuySam/doesitarm / catchRedirectResponse

Function catchRedirectResponse

helpers/astro/request.js:56–74  ·  view source on GitHub ↗
( Astro )

Source from the content-addressed store, hash-verified

54
55
56export async function catchRedirectResponse ( Astro ) {
57 const requestUrl = new URL( Astro.request.url )
58
59 let netlifyRedirectUrl = null
60
61 try {
62 netlifyRedirectUrl = await getNetlifyRedirect( requestUrl.pathname )
63 } catch ( error ) {
64 console.warn( `Skipping redirect lookup for ${ requestUrl.pathname }`, error )
65 }
66
67 // console.log('netlifyRedirectUrl', netlifyRedirectUrl)
68
69 if ( netlifyRedirectUrl !== null ) {
70 return Astro.redirect( netlifyRedirectUrl.to )
71 }
72
73 return null
74}
75

Callers

nothing calls this directly

Calls 1

getNetlifyRedirectFunction · 0.90

Tested by

no test coverage detected