Address code review feedback - use spread operator, fix path parsing logic, remove non-null assertion

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-06 19:43:58 +00:00
parent 03b83b1d7d
commit 04b6f7de3f
2 changed files with 7 additions and 9 deletions

View File

@@ -78,14 +78,11 @@ export async function getSessionUser(_req?: Request): Promise<SessionUser> {
}
// Convert User to Record<string, unknown> for compatibility
// Use spread operator for maintainability
return {
user: {
id: user.id,
username: user.username,
email: user.email,
role: user.role,
...user,
tenantId: user.tenantId ?? null,
createdAt: user.createdAt,
profilePicture: user.profilePicture ?? null,
bio: user.bio ?? null,
isInstanceOwner: user.isInstanceOwner ?? false,

View File

@@ -30,9 +30,9 @@ export function parseRoute(url: string): ParsedRoute {
// Try to extract tenant/package/path from segments
// Pattern: /{tenant}/{package}/...rest
if (segments.length >= 1) {
if (segments.length >= 1 && segments[0] !== undefined) {
const firstSegment = segments[0]
if (firstSegment !== undefined && !isReservedPath(firstSegment)) {
if (!isReservedPath(firstSegment)) {
result.tenant = firstSegment
}
}
@@ -66,8 +66,9 @@ export function getTableName(entity: string, tenantId?: string): string {
}
export function isReservedPath(path: string): boolean {
// Get the first segment of the path
const segment = path.startsWith('/') ? path.split('/')[1] : path.split('/')[0]
// Normalize path to get the first segment
const normalizedPath = path.startsWith('/') ? path.slice(1) : path
const segment = normalizedPath.split('/')[0]
// Check if the segment matches any reserved paths
return segment !== undefined && RESERVED_PATHS.includes(segment)