memos/internal/base/resource_name.go
johnnyjoygh 84776cc106 fix(api): align resource IDs with AIP conventions
Validate new user-provided IDs using the AIP-122 format while retaining legacy UID compatibility. Correct resource annotations and canonical names returned by user stats.
2026-07-18 11:12:28 +08:00

11 lines
456 B
Go

package base
import "regexp"
var (
// ResourceIDMatcher matches new user-provided resource IDs per AIP-122.
ResourceIDMatcher = regexp.MustCompile(`^[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$`)
// UIDMatcher also accepts the previous 36-character format so existing
// generated and persisted UIDs remain writable by the store layer.
UIDMatcher = regexp.MustCompile(`^(?:[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?|[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?)$`)
)