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

Function getNetlifyRedirect

helpers/config-node.js:173–198  ·  view source on GitHub ↗
( path )

Source from the content-addressed store, hash-verified

171}
172
173export async function getNetlifyRedirect ( path ) {
174 // Check if the path is valid
175 // by checking if it starts with a slash
176 // and does not end with a slash
177 // if ( !path.startsWith('/') || path.endsWith('/') ) {
178 // throw new Error(`Invalid Netlify redirect path: ${ path }`)
179 // }
180
181 const netlifyConfig = await getNetlifyConfig()
182 const redirects = netlifyConfig.redirects
183
184 for ( const redirect of redirects ) {
185 // Check if the from path is valid
186 // by checking if it starts with a slash
187 // and does not end with a slash
188 if ( !redirect.from.startsWith('/') || redirect.from.endsWith('/') ) {
189 throw new Error(`Invalid Netlify redirect.from path: ${ redirect.from }`)
190 }
191
192 if ( redirect.from === path ) {
193 return redirect
194 }
195 }
196
197 return null
198}
199
200export function makeTitle ( listing ) {
201 return `Does ${ listing.name } work on Apple Silicon? - ${ nuxtHead.title }`

Callers 2

catchRedirectResponseFunction · 0.90

Calls 1

getNetlifyConfigFunction · 0.85

Tested by

no test coverage detected