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

Function createRouter

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

Source from the content-addressed store, hash-verified

17}
18
19export function createRouter(routes, defaultBackend = null) {
20 const sortedRoutes = Object.entries(routes).sort(
21 ([a], [b]) => b.length - a.length,
22 );
23
24 return function route(url) {
25 for (const [prefix, backend] of sortedRoutes) {
26 if (matchesPathPrefix(url, prefix)) {
27 return backend;
28 }
29 }
30 return defaultBackend;
31 };
32}
33
34export function isBenignSocketError(err) {
35 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