change ids
This commit is contained in:
@@ -156,9 +156,12 @@ func OwnershipProxyMiddleware(pool *SyncedPool) func(http.Handler) http.Handler
|
||||
func extractCartIdFromRequest(r *http.Request) (CartId, bool) {
|
||||
// Cookie
|
||||
if c, err := r.Cookie("cartid"); err == nil && c.Value != "" {
|
||||
if cid, _, _, err2 := CanonicalizeOrLegacy(c.Value); err2 == nil {
|
||||
return CartIDToLegacy(cid), true
|
||||
if parsed, ok := ParseCartId(c.Value); ok {
|
||||
return parsed, true
|
||||
}
|
||||
// Invalid existing cookie value: issue a fresh id (breaking change behavior)
|
||||
newId := MustNewCartId()
|
||||
return newId, true
|
||||
}
|
||||
// Path-based: locate "byid" segment
|
||||
parts := splitPath(r.URL.Path)
|
||||
@@ -166,8 +169,8 @@ func extractCartIdFromRequest(r *http.Request) (CartId, bool) {
|
||||
if parts[i] == "byid" && i+1 < len(parts) {
|
||||
raw := parts[i+1]
|
||||
if raw != "" {
|
||||
if cid, _, _, err := CanonicalizeOrLegacy(raw); err == nil {
|
||||
return CartIDToLegacy(cid), true
|
||||
if parsed, ok := ParseCartId(raw); ok {
|
||||
return parsed, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user