({
entrypoint,
files,
requestPath,
})
| 1366 | }; |
| 1367 | |
| 1368 | export const defaultShouldServe: ShouldServe = ({ |
| 1369 | entrypoint, |
| 1370 | files, |
| 1371 | requestPath, |
| 1372 | }) => { |
| 1373 | requestPath = requestPath.replace(/\/$/, ''); // sanitize trailing '/' |
| 1374 | entrypoint = entrypoint.replace(/\\/g, '/'); // windows compatibility |
| 1375 | |
| 1376 | if (entrypoint === requestPath && hasProp(files, entrypoint)) { |
| 1377 | return true; |
| 1378 | } |
| 1379 | |
| 1380 | const { dir, name } = parse(entrypoint); |
| 1381 | if (name === 'index' && dir === requestPath && hasProp(files, entrypoint)) { |
| 1382 | return true; |
| 1383 | } |
| 1384 | |
| 1385 | return false; |
| 1386 | }; |
| 1387 | |
| 1388 | function hasProp(obj: { [path: string]: FileFsRef }, key: string): boolean { |
| 1389 | return Object.hasOwnProperty.call(obj, key); |
no test coverage detected