@@ -6,7 +6,6 @@ import { configService, Log, Webhook } from '@config/env.config';
66import { Logger } from '@config/logger.config' ;
77import { BadRequestException } from '@exceptions' ;
88import axios , { AxiosInstance } from 'axios' ;
9- import { isURL } from 'class-validator' ;
109
1110import { EmitData , EventController , EventControllerInterface } from '../event.controller' ;
1211
@@ -18,7 +17,7 @@ export class WebhookController extends EventController implements EventControlle
1817 }
1918
2019 override async set ( instanceName : string , data : EventDto ) : Promise < wa . LocalWebHook > {
21- if ( ! isURL ( data . webhook . url , { require_tld : false } ) ) {
20+ if ( ! / ^ ( h t t p s ? : \/ \/ ) / . test ( data . webhook . url ) ) {
2221 throw new BadRequestException ( 'Invalid "url" property' ) ;
2322 }
2423
@@ -78,6 +77,7 @@ export class WebhookController extends EventController implements EventControlle
7877 const we = event . replace ( / [ . - ] / gm, '_' ) . toUpperCase ( ) ;
7978 const transformedWe = we . replace ( / _ / gm, '-' ) . toLowerCase ( ) ;
8079 const enabledLog = configService . get < Log > ( 'LOG' ) . LEVEL . includes ( 'WEBHOOKS' ) ;
80+ const regex = / ^ ( h t t p s ? : \/ \/ ) / ;
8181
8282 const webhookData = {
8383 event,
@@ -111,7 +111,7 @@ export class WebhookController extends EventController implements EventControlle
111111 }
112112
113113 try {
114- if ( instance ?. enabled && isURL ( instance . url , { require_tld : false } ) ) {
114+ if ( instance ?. enabled && regex . test ( instance . url ) ) {
115115 const httpService = axios . create ( {
116116 baseURL,
117117 headers : webhookHeaders as Record < string , string > | undefined ,
@@ -155,7 +155,7 @@ export class WebhookController extends EventController implements EventControlle
155155 }
156156
157157 try {
158- if ( isURL ( globalURL ) ) {
158+ if ( regex . test ( globalURL ) ) {
159159 const httpService = axios . create ( { baseURL : globalURL } ) ;
160160
161161 await this . retryWebhookRequest (
0 commit comments