1- import axios , { AxiosError } from 'axios' ;
1+ import axios from 'axios' ;
22
33
44
5- type providers = 'isgd' | 'cdpt' | 'vgd' | '4hnet' | 'tinube' | 'rbgy' | 'vurl' ;
5+ type providers = 'isgd' | 'cdpt' | 'vgd' | '4hnet' | 'tinube' | 'rbgy' | 'vurl' | 'haha' | 'pwm' | 'cya' ;
66
77/**
88 *
@@ -46,7 +46,7 @@ interface IProviders {
4646 * @param {string } longUrl
4747 * @return {* } {IResponse}
4848 */
49- function responseMap ( response : Record < any , any > , longUrl : string ) : IResponse {
49+ function responseMap ( response : Record < any , any > , longUrl : string , provider : providers ) : IResponse {
5050 const responseType = response . headers [ 'content-type' ] . split ( ';' ) [ 0 ] ;
5151 if ( ! [ 'text/plain' , 'text/html' ] . includes ( responseType ) ) {
5252 if ( response . data ?. url ) {
@@ -62,7 +62,19 @@ function responseMap(response: Record<any, any>, longUrl: string): IResponse {
6262 }
6363 }
6464
65- return { longUrl, shortUrl : response . data } ;
65+ if ( [ 'haha' , 'pwm' , 'cya' ] . includes ( provider ) ) {
66+
67+
68+ return { longUrl, shortUrl : `https://${ provider } .se/${ response . data } ` } ;
69+
70+ }
71+
72+
73+ return { longUrl, shortUrl : response . data } ;
74+
75+
76+
77+
6678}
6779
6880
@@ -97,13 +109,26 @@ const ValidProviders: Record<string, IProviders> = {
97109 url : 'https://v.gd/create.php?format=simple&url=' ,
98110 method : 'get' ,
99111 } ,
112+ haha : {
113+ url : 'https://www.haha.se/lank.php?dataLank=' ,
114+ method : 'get' ,
115+ } ,
116+
117+ cya : {
118+ url : 'https://www.haha.se/lank.php?dataLank=' ,
119+ method : 'get' ,
120+ } ,
121+
122+ pwm : {
123+ url : 'https://www.haha.se/lank.php?dataLank=' ,
124+ method : 'get' ,
125+ } ,
100126
101127 '4hnet' : {
102128 url : 'https://4h.net/api/?url=' ,
103129 method : 'get' ,
104130 } ,
105131
106-
107132 vurl : {
108133 url : 'https://vurl.com/api.php?url=' ,
109134 method : 'get' ,
@@ -145,7 +170,7 @@ export default async (
145170 longUrl ,
146171 option ,
147172 ) ;
148- return responseMap ( response , longUrl ) ;
173+ return responseMap ( response , longUrl , option . provider ) ;
149174 } catch ( error ) {
150175 throw error ;
151176 }
0 commit comments