@@ -159,9 +159,28 @@ function makeCurrentStrategies(platform, overrides = {}) {
159159function currentEntryForAccount ( state , platform , account ) {
160160 const byPlatform = state . currentStrategies [ platform ] || { } ;
161161 const normalizeAccountLookupKey = ( value ) => String ( value || "" ) . trim ( ) . toLowerCase ( ) ;
162+ const collectAccountLookupCandidates = ( keys ) => {
163+ const candidates = new Set ( ) ;
164+ for ( const rawKey of keys ) {
165+ const key = normalizeAccountLookupKey ( rawKey ) ;
166+ if ( ! key ) continue ;
167+
168+ candidates . add ( key ) ;
169+
170+ const compact = key . replace ( / [ ^ a - z 0 - 9 ] + / g, "" ) ;
171+ if ( compact ) candidates . add ( compact ) ;
172+
173+ const parts = key . split ( / [ ^ a - z 0 - 9 ] + / ) . filter ( Boolean ) ;
174+ for ( const part of parts ) candidates . add ( part ) ;
175+ if ( parts . length > 1 ) {
176+ candidates . add ( parts [ parts . length - 1 ] ) ;
177+ }
178+ }
179+ return [ ...candidates ] ;
180+ } ;
162181 const keys = [ account ?. key , account ?. target_name , account ?. label ] . filter ( Boolean ) . map ( String ) ;
163182
164- const candidates = [ ... new Set ( keys . map ( normalizeAccountLookupKey ) . filter ( Boolean ) ) ] ;
183+ const candidates = new Set ( collectAccountLookupCandidates ( keys ) ) ;
165184
166185 for ( const key of keys ) {
167186 const entry = byPlatform [ key ] ;
@@ -175,7 +194,9 @@ function currentEntryForAccount(state, platform, account) {
175194
176195 for ( const [ rawKey , entry ] of Object . entries ( byPlatform ) ) {
177196 if ( ! entry || typeof entry !== "object" ) continue ;
178- if ( candidates . includes ( normalizeAccountLookupKey ( rawKey ) ) ) {
197+ const rawCandidates = collectAccountLookupCandidates ( [ rawKey ] ) ;
198+ const hasMatch = rawCandidates . some ( ( candidate ) => candidates . has ( candidate ) ) ;
199+ if ( hasMatch ) {
179200 if ( ! entry . strategy_profile ) {
180201 return {
181202 ...entry ,
@@ -1056,6 +1077,40 @@ console.log("\n=== 11. currentEntryForAccount 映射健壮性 ===\n");
10561077 assert ( entry ?. strategy_profile === "soxl_soxx_trend_income" , "11e: existing strategy_profile should be preserved" ) ;
10571078}
10581079
1080+ // 11f: 账号 key 带平台前缀时能命中(longbridge sg -> sg)
1081+ {
1082+ const state = {
1083+ currentStrategies : {
1084+ longbridge : {
1085+ sg : { runtime_target_enabled : true } ,
1086+ } ,
1087+ } ,
1088+ } ;
1089+ const account = {
1090+ key : "longbridge sg" ,
1091+ label : "LongBridge SG" ,
1092+ } ;
1093+ const entry = currentEntryForAccount ( state , "longbridge" , account ) ;
1094+ assert ( entry && entry . runtime_target_enabled === true , "11f: platform-prefixed key should fallback-match by token" ) ;
1095+ }
1096+
1097+ // 11g: 账号 key 带分隔符时能命中(longbridge-sg / LB|SG)
1098+ {
1099+ const state = {
1100+ currentStrategies : {
1101+ longbridge : {
1102+ sg : { runtime_target_enabled : true } ,
1103+ } ,
1104+ } ,
1105+ } ;
1106+ const account = {
1107+ key : "longbridge-sg" ,
1108+ label : "LB|SG" ,
1109+ } ;
1110+ const entry = currentEntryForAccount ( state , "longbridge" , account ) ;
1111+ assert ( entry && entry . runtime_target_enabled === true , "11g: separator variants should fallback-match" ) ;
1112+ }
1113+
10591114// ============================================================
10601115// 12. syncOptionOverlayForAccount (解析为具体值)
10611116// ============================================================
0 commit comments