File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
apps/array/src/shared/utils Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 1+ import { randomBytes } from "node:crypto" ;
2+
13export function randomSuffix ( length = 8 ) : string {
2- return Math . random ( )
3- . toString ( 36 )
4- . substring ( 2 , 2 + length ) ;
4+ return randomBytes ( length ) . toString ( "hex" ) . substring ( 0 , length ) ;
55}
66
77export function generateId ( prefix : string , length = 8 ) : string {
Original file line number Diff line number Diff line change 1+ import { randomBytes } from "node:crypto" ;
12import type {
23 ClientCapabilities ,
34 TerminalOutputResponse ,
@@ -719,7 +720,7 @@ export function replaceAndCalculateLocation(
719720 let currentContent = fileContent ;
720721
721722 // Use unique markers to track where replacements happen
722- const markerPrefix = `__REPLACE_MARKER_${ Math . random ( ) . toString ( 36 ) . substr ( 2 , 9 ) } _` ;
723+ const markerPrefix = `__REPLACE_MARKER_${ randomBytes ( 5 ) . toString ( "hex" ) } _` ;
723724 let markerCounter = 0 ;
724725 const markers : string [ ] = [ ] ;
725726
Original file line number Diff line number Diff line change 11import { exec , execFile } from "node:child_process" ;
2+ import * as crypto from "node:crypto" ;
23import * as fs from "node:fs/promises" ;
34import * as path from "node:path" ;
45import { promisify } from "node:util" ;
@@ -523,7 +524,7 @@ export class WorktreeManager {
523524 }
524525
525526 private randomElement < T > ( array : T [ ] ) : T {
526- return array [ Math . floor ( Math . random ( ) * array . length ) ] ;
527+ return array [ crypto . randomInt ( array . length ) ] ;
527528 }
528529
529530 generateWorktreeName ( ) : string {
You can’t perform that action at this time.
0 commit comments