File size: 466 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
type PartialReq = {
	originalUrl: string;
};

const STATIC_PATHS = [
	'/calypso/',
	'/service-worker',
	'/nostats.js',
	'/__webpack_hmr',
	'_favicon.ico',
];

/**
 * Returns true if the request is to a static file, like JS bundles.
 * @param req The express request object
 */
export default function isStaticRequest( req: PartialReq ) {
	if ( ! req?.originalUrl ) {
		return false;
	}

	return STATIC_PATHS.some( ( path ) => req.originalUrl.startsWith( path ) );
}