File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
packages/react-router/lib/rsc Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -723,15 +723,32 @@ const discoveredPaths = new Set<string>();
723
723
// https://stackoverflow.com/a/417184
724
724
const URL_LIMIT = 7680 ;
725
725
726
+ function getManifestUrl ( paths : string [ ] ) : URL | null {
727
+ if ( paths . length === 0 ) {
728
+ return null ;
729
+ }
730
+
731
+ if ( paths . length === 1 ) {
732
+ return new URL ( `${ paths [ 0 ] } .manifest` , window . location . origin ) ;
733
+ }
734
+
735
+ let basename = ( window . __router . basename ?? "" ) . replace ( / ^ \/ | \/ $ / g, "" ) ;
736
+ let url = new URL ( `${ basename } /.manifest` , window . location . origin ) ;
737
+ paths . sort ( ) . forEach ( ( path ) => url . searchParams . append ( "p" , path ) ) ;
738
+
739
+ return url ;
740
+ }
741
+
726
742
async function fetchAndApplyManifestPatches (
727
743
paths : string [ ] ,
728
744
decode : DecodeServerResponseFunction ,
729
745
fetchImplementation : ( request : Request ) => Promise < Response > ,
730
746
signal ?: AbortSignal
731
747
) {
732
- let basename = ( window . __router . basename ?? "" ) . replace ( / ^ \/ | \/ $ / g, "" ) ;
733
- let url = new URL ( `${ basename } /.manifest` , window . location . origin ) ;
734
- paths . sort ( ) . forEach ( ( path ) => url . searchParams . append ( "p" , path ) ) ;
748
+ let url = getManifestUrl ( paths ) ;
749
+ if ( url == null ) {
750
+ return ;
751
+ }
735
752
736
753
// If the URL is nearing the ~8k limit on GET requests, skip this optimization
737
754
// step and just let discovery happen on link click. We also wipe out the
You can’t perform that action at this time.
0 commit comments