@@ -67,32 +67,30 @@ class AngularAssetsMiddleware {
6767 ) { }
6868
6969 handle ( req : IncomingMessage , res : ServerResponse , next : ( err ?: unknown ) => unknown ) {
70- let err = null ;
71- try {
72- const url = new URL ( `http://${ req . headers [ 'host' ] } ${ req . url } ` ) ;
73- // Remove the leading slash from the URL path and convert to platform specific.
74- // The latest build files will use the platform path separator.
75- let pathname = url . pathname . slice ( 1 ) ;
76- if ( isWindows ) {
77- pathname = pathname . replaceAll ( path . posix . sep , path . win32 . sep ) ;
78- }
70+ const url = new URL ( `http://${ req . headers [ 'host' ] } ${ req . url } ` ) ;
71+ // Remove the leading slash from the URL path and convert to platform specific.
72+ // The latest build files will use the platform path separator.
73+ let pathname = url . pathname . slice ( 1 ) ;
74+ if ( isWindows ) {
75+ pathname = pathname . replaceAll ( path . posix . sep , path . win32 . sep ) ;
76+ }
7977
80- const file = this . latestBuildFiles . files [ pathname ] ;
78+ const file = this . latestBuildFiles . files [ pathname ] ;
79+ if ( ! file ) {
80+ next ( ) ;
8181
82- if ( file ?. origin === 'disk' ) {
83- this . serveFile ( file . inputPath , undefined , res ) ;
82+ return ;
83+ }
8484
85- return ;
86- } else if ( file ?. origin === 'memory' ) {
85+ switch ( file . origin ) {
86+ case 'disk' :
87+ this . serveFile ( file . inputPath , undefined , res ) ;
88+ break ;
89+ case 'memory' :
8790 // Include pathname to help with Content-Type headers.
8891 this . serveFile ( `/unused/${ url . pathname } ` , undefined , res , undefined , file . contents , true ) ;
89-
90- return ;
91- }
92- } catch ( e ) {
93- err = e ;
92+ break ;
9493 }
95- next ( err ) ;
9694 }
9795
9896 static createPlugin ( initialFiles : LatestBuildFiles ) : InlinePluginDef {
0 commit comments