File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ export default async function (msg: Message) {
1414
1515 const text = `
1616 \`Canis for WhatsApp\`
17- mrepol742/project-canis
17+ https://github.com/ mrepol742/project-canis
1818
1919 \`Canis for Telegram\`
20- mrepol742/project-canis-ts
20+ https://github.com/ mrepol742/project-canis-ts
2121
2222 This bot is not affiliated, endorsed, partner, or connected to Meta.
2323 Use it at your own RISK.
Original file line number Diff line number Diff line change @@ -64,25 +64,24 @@ const mathSansMap: Record<string, string> = {
6464} ;
6565
6666export default function ( text : string ) {
67- // Regex to match URLs
6867 const urlRegex = / ( h t t p s ? : \/ \/ [ ^ \s ] + | w w w \. [ ^ \s ] + ) / g;
6968 let result = "" ;
7069 let lastIndex = 0 ;
7170
72- // Find all URLs and skip conversion for them
73- text . replace ( urlRegex , ( url , index ) => {
74- // Convert text before URL
71+ for ( const match of text . matchAll ( urlRegex ) ) {
72+ const url = match [ 0 ] ;
73+ const index = match . index ! ;
74+
7575 for ( let i = lastIndex ; i < index ; i ++ ) {
7676 const char = text [ i ] ;
7777 result += mathSansMap [ char ] || char ;
7878 }
79- // Add URL as is
79+
8080 result += url ;
81+
8182 lastIndex = index + url . length ;
82- return url ;
83- } ) ;
83+ }
8484
85- // Convert remaining text after last URL
8685 for ( let i = lastIndex ; i < text . length ; i ++ ) {
8786 const char = text [ i ] ;
8887 result += mathSansMap [ char ] || char ;
You can’t perform that action at this time.
0 commit comments