ZDDC/zddc/internal/handler/projecthandler.go
2026-06-11 13:32:31 -05:00

32 lines
962 B
Go

package handler
import (
"strings"
)
// IsProjectRootURL reports whether urlPath names a project root —
// exactly one path segment, no trailing slash. Used by the dispatcher
// to route /<project> (no trailing slash) to the landing tool's
// project-workspace mode rather than the historical redirect-to-slash.
//
// Examples:
//
// "/Project-1" → true
// "/Project-1/" → false (trailing slash → directory listing)
// "/Project-1/x" → false (deeper)
// "/" → false (deployment root)
// "" → false
//
// The actual page rendering lives client-side in landing/js/landing.js
// (mode='project'); this server-side predicate only decides where to
// route the request.
func IsProjectRootURL(urlPath string) bool {
if urlPath == "" || urlPath == "/" {
return false
}
if strings.HasSuffix(urlPath, "/") {
return false
}
trimmed := strings.TrimPrefix(urlPath, "/")
return !strings.Contains(trimmed, "/")
}