UNPKG

703 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const path_1 = require("path");
4function shouldServe({ entrypoint, files, requestPath, }) {
5 requestPath = requestPath.replace(/\/$/, ''); // sanitize trailing '/'
6 entrypoint = entrypoint.replace(/\\/, '/'); // windows compatibility
7 if (entrypoint === requestPath && hasProp(files, entrypoint)) {
8 return true;
9 }
10 const { dir, name } = path_1.parse(entrypoint);
11 if (name === 'index' && dir === requestPath && hasProp(files, entrypoint)) {
12 return true;
13 }
14 return false;
15}
16exports.default = shouldServe;
17function hasProp(obj, key) {
18 return Object.hasOwnProperty.call(obj, key);
19}