1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const constants_1 = require("./constants");
|
7 | const mime_types_1 = __importDefault(require("mime-types"));
|
8 | async function a_sume(fn, throws) {
|
9 | try {
|
10 | return await fn();
|
11 | }
|
12 | catch (e) {
|
13 | throw throws(e);
|
14 | }
|
15 | }
|
16 | exports.a_sume = a_sume;
|
17 | function s_sume(fn, throws) {
|
18 | try {
|
19 | return fn();
|
20 | }
|
21 | catch (e) {
|
22 | throw throws(e);
|
23 | }
|
24 | }
|
25 | exports.s_sume = s_sume;
|
26 | function filenameOutsideFabLocations(filename) {
|
27 | return filename !== '/server.js' && !filename.startsWith('/_assets/');
|
28 | }
|
29 | exports.filenameOutsideFabLocations = filenameOutsideFabLocations;
|
30 | function getContentType(pathname) {
|
31 | const mimeType = mime_types_1.default.lookup(pathname);
|
32 | return (mimeType && mime_types_1.default.contentType(mimeType)) || constants_1.DEFAULT_MIME_TYPE;
|
33 | }
|
34 | exports.getContentType = getContentType;
|
35 | function getCacheHeaders(immutable) {
|
36 | return immutable ? constants_1.IMMUTABLE_HEADERS : constants_1.NON_IMMUTABLE_HEADERS;
|
37 | }
|
38 | exports.getCacheHeaders = getCacheHeaders;
|
39 | function matchPath(lookup_table, _pathname) {
|
40 | const pathname = decodeURIComponent(_pathname);
|
41 | return (lookup_table[pathname] ||
|
42 | lookup_table[pathname + '.html'] ||
|
43 | lookup_table[`${pathname}${pathname.endsWith('/') ? '' : '/'}index.html`]);
|
44 | }
|
45 | exports.matchPath = matchPath;
|
46 | exports.stripTrailingSlash = (str) => str.replace(/\/$/, '');
|
47 |
|
\ | No newline at end of file |