UNPKG

1.11 kBJavaScriptView Raw
1import { DEFAULT_MIME_TYPE, IMMUTABLE_HEADERS, NON_IMMUTABLE_HEADERS } from './constants';
2import mime from 'mime-types';
3export async function a_sume(fn, throws) {
4 try {
5 return await fn();
6 }
7 catch (e) {
8 throw throws(e);
9 }
10}
11export function s_sume(fn, throws) {
12 try {
13 return fn();
14 }
15 catch (e) {
16 throw throws(e);
17 }
18}
19export function filenameOutsideFabLocations(filename) {
20 return filename !== '/server.js' && !filename.startsWith('/_assets/');
21}
22export function getContentType(pathname) {
23 const mimeType = mime.lookup(pathname);
24 return (mimeType && mime.contentType(mimeType)) || DEFAULT_MIME_TYPE;
25}
26export function getCacheHeaders(immutable) {
27 return immutable ? IMMUTABLE_HEADERS : NON_IMMUTABLE_HEADERS;
28}
29export function matchPath(lookup_table, pathname) {
30 return (lookup_table[pathname] ||
31 lookup_table[pathname + '.html'] ||
32 lookup_table[`${pathname}${pathname.endsWith('/') ? '' : '/'}index.html`]);
33}
34export const stripTrailingSlash = (str) => str.replace(/\/$/, '');
35//# sourceMappingURL=helpers.js.map
\No newline at end of file