MCPcopy Create free account
hub / github.com/DIYgod/RSSHub / resolveModuleNamespace

Function resolveModuleNamespace

lib/registry.ts:41–50  ·  view source on GitHub ↗
(moduleKey: string, roots: Set<string>)

Source from the content-addressed store, hash-verified

39 * path segment (flat namespaces). `location` is the module path relative to the resolved namespace root.
40 */
41export function resolveModuleNamespace(moduleKey: string, roots: Set<string>): { namespace: string; location: string } {
42 const segments = moduleKey.split(SEPARATOR).filter(Boolean);
43 for (let i = segments.length - 1; i >= 1; i--) {
44 const candidate = segments.slice(0, i).join('/');
45 if (roots.has(candidate)) {
46 return { namespace: candidate, location: segments.slice(i).join('/') };
47 }
48 }
49 return { namespace: segments[0], location: segments.slice(1).join('/') };
50}
51
52function isSafeRoutes(routes: RoutesType): boolean {
53 return Object.values(routes).every((route: Route) => !route.features?.nsfw);

Callers 2

registry.test.tsFile · 0.90
registry.tsFile · 0.85

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected