import { parse } from 'path' ; import { ShouldServeOptions } from './types' ; import FileFsRef from './file-fs-ref' ; export default function shouldServe ( { entrypoint , files , requestPath , } ) { requestPath = requestPath . replace ( /\/$/ , '' ) ; entrypoint = entrypoint . replace ( /\\/ , '/' ) ; if ( entrypoint === requestPath && hasProp ( files , entrypoint ) ) { return true ; } const { dir , name } = parse ( entrypoint ) ; if ( name === 'index' && dir === requestPath && hasProp ( files , entrypoint ) ) { return true ; } return false ; } function hasProp ( obj , key ) { return Object . hasOwnProperty . call ( obj , key ) ; }