File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ const brainrotDict: Record<string, string[]> = {
3333function toBrainrot ( text : string ) : string {
3434 let result = text ;
3535 Object . entries ( brainrotDict ) . forEach ( ( [ word , replacements ] ) => {
36- const regex = new RegExp ( `\\ b${ word } \ \b` , 'gi' ) ;
36+ const regex = new RegExp ( `\b${ word } \b` , 'gi' ) ;
3737 result = result . replace ( regex , ( ) => replacements [ Math . floor ( Math . random ( ) * replacements . length ) ] ) ;
3838 } ) ;
3939 // Add some random brainrot filler
@@ -54,10 +54,14 @@ export default function BrainRot() {
5454 setOutput ( toBrainrot ( input ) ) ;
5555 } ;
5656
57- const copy = ( ) => {
58- navigator . clipboard . writeText ( output ) ;
59- setCopied ( true ) ;
60- setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
57+ const copy = async ( ) => {
58+ try {
59+ await navigator . clipboard . writeText ( output ) ;
60+ setCopied ( true ) ;
61+ setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
62+ } catch {
63+ // Clipboard failed (non-secure context), silently ignore
64+ }
6165 } ;
6266
6367 return (
You can’t perform that action at this time.
0 commit comments