fix: remove unused sanitizeCustomMenuItemsJSON function

Replaced by filterUserVisibleMenuItems which includes both array
validation and admin-item filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
erio
2026-03-03 07:13:08 +08:00
parent e97c376681
commit 451a851118

View File

@@ -244,22 +244,6 @@ func (s *SettingService) GetPublicSettingsForInjection(ctx context.Context) (any
}, nil
}
// sanitizeCustomMenuItemsJSON validates a raw JSON string is a valid JSON array
// and returns it as json.RawMessage. Returns "[]" if the input is empty, not a
// valid JSON array, or is a non-array JSON value (e.g. object, string).
func sanitizeCustomMenuItemsJSON(raw string) json.RawMessage {
raw = strings.TrimSpace(raw)
if raw == "" || raw == "[]" {
return json.RawMessage("[]")
}
// Verify it's actually a JSON array, not an object or other type
var arr []json.RawMessage
if err := json.Unmarshal([]byte(raw), &arr); err != nil {
return json.RawMessage("[]")
}
return json.RawMessage(raw)
}
// filterUserVisibleMenuItems filters out admin-only menu items from a raw JSON
// array string, returning only items with visibility != "admin".
func filterUserVisibleMenuItems(raw string) json.RawMessage {