mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-06 22:01:44 +08:00
Zhipu's `data.limits[]` returns 1 entry for legacy plans (subscribed before 2026-02-12) and 2 entries for current plans. Previously every TOKENS_LIMIT entry was hardcoded as `five_hour`, so the weekly bucket was rendered with the 5-hour i18n label. Sort TOKENS_LIMIT entries by nextResetTime ascending and assign `five_hour` to index 0, `weekly_limit` to index 1. Legacy plans naturally degrade to a single five_hour tier. Also harden the parser: case-insensitive type match (defends against upstream casing changes), reuse TIER_FIVE_HOUR/TIER_WEEKLY_LIMIT constants, and add 8 unit tests covering both plan shapes plus defensive edge cases.