Files
flights_web_raw/node_modules/hono/dist/middleware/serve-static/index.js
T
gnezim 60e2149072 Add comprehensive e2e test suites for Tasks 16-25
Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date)
- Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class
- Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting
- Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states
- Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions
- Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation

Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares)
- Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline
- Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements
- Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations
- Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary
- Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds

All tests follow AAA pattern and use data-testid selectors matching Angular version.
Total: 245 tests across 10 feature suites.
2026-04-05 19:25:03 +03:00

78 lines
2.4 KiB
JavaScript

// src/middleware/serve-static/index.ts
import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../../utils/compress.js";
import { getMimeType } from "../../utils/mime.js";
import { tryDecodeURI } from "../../utils/url.js";
import { defaultJoin } from "./path.js";
var ENCODINGS = {
br: ".br",
zstd: ".zst",
gzip: ".gz"
};
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
var DEFAULT_DOCUMENT = "index.html";
var serveStatic = (options) => {
const root = options.root ?? "./";
const optionPath = options.path;
const join = options.join ?? defaultJoin;
return async (c, next) => {
if (c.finalized) {
return next();
}
let filename;
if (options.path) {
filename = options.path;
} else {
try {
filename = tryDecodeURI(c.req.path);
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
throw new Error();
}
} catch {
await options.onNotFound?.(c.req.path, c);
return next();
}
}
let path = join(
root,
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename
);
if (options.isDir && await options.isDir(path)) {
path = join(path, DEFAULT_DOCUMENT);
}
const getContent = options.getContent;
let content = await getContent(path, c);
if (content instanceof Response) {
return c.newResponse(content.body, content);
}
if (content) {
const mimeType = options.mimes && getMimeType(path, options.mimes) || getMimeType(path);
c.header("Content-Type", mimeType || "application/octet-stream");
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
const acceptEncodingSet = new Set(
c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim())
);
for (const encoding of ENCODINGS_ORDERED_KEYS) {
if (!acceptEncodingSet.has(encoding)) {
continue;
}
const compressedContent = await getContent(path + ENCODINGS[encoding], c);
if (compressedContent) {
content = compressedContent;
c.header("Content-Encoding", encoding);
c.header("Vary", "Accept-Encoding", { append: true });
break;
}
}
}
await options.onFound?.(path, c);
return c.body(content);
}
await options.onNotFound?.(path, c);
await next();
return;
};
};
export {
serveStatic
};