Browse Source

Fix #190

findaccounts with 'name' and 'exact:false' not working as expected
PascalCoin 6 năm trước cách đây
mục cha
commit
180155e23d
2 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 4 1
      src/core/UBaseTypes.pas
  2. 1 1
      src/core/URPC.pas

+ 4 - 1
src/core/UBaseTypes.pas

@@ -370,9 +370,12 @@ end;
 class function TBaseType.StartsWith(const subst, target: TRawBytes): Boolean;
 var i : Integer;
 begin
+  if (Length(target)<Length(subst)) then begin
+    Exit(False);
+  end;
   i := Low(subst);
   while (i<=High(subst)) and (i<=High(target)) and (target[i]=subst[i]) do inc(i);
-  Result := (i>High(subst)) and (i>High(target));
+  Result := (i>High(subst));
 end;
 
 class procedure TBaseType.Concat(const addBytes: T32Bytes; var target: TDynRawBytes);

+ 1 - 1
src/core/URPC.pas

@@ -2484,7 +2484,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
            Continue;
         end;
 
-        if ((Length(accountName)>0) AND (TBaseType.StartsWith(accountName,account.name))) then
+        if ((Length(accountName)>0) AND (Not TBaseType.StartsWith(accountName,account.name))) then
         begin
           Continue
         end;