(moduleKey: string, roots: Set<string>)
| 39 | * path segment (flat namespaces). `location` is the module path relative to the resolved namespace root. |
| 40 | */ |
| 41 | export 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 | |
| 52 | function isSafeRoutes(routes: RoutesType): boolean { |
| 53 | return Object.values(routes).every((route: Route) => !route.features?.nsfw); |
no test coverage detected