MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / createRouter

Function createRouter

scripts/proxy-utils.mjs:22–35  ·  view source on GitHub ↗
(routes, defaultBackend = null)

Source from the content-addressed store, hash-verified

20}
21
22export function createRouter(routes, defaultBackend = null) {
23 const sortedRoutes = Object.entries(routes).sort(
24 ([a], [b]) => b.length - a.length,
25 );
26
27 return function route(url) {
28 for (const [prefix, backend] of sortedRoutes) {
29 if (matchesPathPrefix(url, prefix)) {
30 return backend;
31 }
32 }
33 return defaultBackend;
34 };
35}
36
37export function isBenignSocketError(err) {
38 return Boolean(err && BENIGN_SOCKET_ERRORS.has(err.code));

Callers 2

startStaticServerFunction · 0.90
startIngressFunction · 0.90

Calls 1

matchesPathPrefixFunction · 0.85

Tested by

no test coverage detected