File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,18 @@ export default {
7373 const redirects : Redirects = await redirectsResponse . json ( ) ;
7474
7575 for ( const redirect of redirects ) {
76- if (
77- ( redirect . kind === "static" && requestUrl . pathname === redirect . from )
78- || ( redirect . kind === "dynamic" && requestUrl . pathname . startsWith ( redirect . from ) )
79- ) {
76+ if ( redirect . kind === "static" && requestUrl . pathname === redirect . from ) {
8077 const url = new URL ( request . url ) ;
8178 url . pathname = redirect . to ;
8279 return Response . redirect ( url . toString ( ) , redirect . status ) ;
8380 }
81+
82+ if ( redirect . kind === "dynamic" && requestUrl . pathname . startsWith ( redirect . from ) ) {
83+ const url = new URL ( request . url ) ;
84+ const suffix = requestUrl . pathname . slice ( redirect . from . length ) ;
85+ url . pathname = redirect . to + suffix ;
86+ return Response . redirect ( url . toString ( ) , redirect . status ) ;
87+ }
8488 }
8589
8690 const response = await env . ASSETS . fetch ( request ) ;
You can’t perform that action at this time.
0 commit comments