@@ -542,20 +542,8 @@ export class Filelink {
542
542
* @memberof Filelink
543
543
*/
544
544
constructor ( source : string | string [ ] , apikey ?: string ) {
545
- this . source = source ;
546
- const isExternal = this . isSourceExternal ( ) ;
547
-
548
- debug ( `Source ${ source } - isExternal? ${ isExternal } ` ) ;
549
-
550
- if ( isExternal && ! apikey ) {
551
- throw new FilestackError ( 'External sources requires apikey to handle transforms' ) ;
552
- }
553
-
554
- if ( ! isExternal && typeof this . source === 'string' && ! handleRegexp . test ( this . source ) ) {
555
- throw new FilestackError ( 'Invalid filestack source provided' ) ;
556
- }
557
-
558
545
this . apikey = apikey ;
546
+ this . setSource ( source ) ;
559
547
}
560
548
561
549
/**
@@ -606,6 +594,22 @@ export class Filelink {
606
594
return this ;
607
595
}
608
596
597
+ setSource ( source : string | string [ ] ) {
598
+ this . source = source ;
599
+
600
+ const isExternal = this . isSourceExternal ( ) ;
601
+
602
+ debug ( `Source ${ source } - isExternal? ${ isExternal } ` ) ;
603
+
604
+ if ( isExternal && ! this . apikey ) {
605
+ throw new FilestackError ( 'External sources requires apikey to handle transforms' ) ;
606
+ }
607
+
608
+ if ( ! isExternal && typeof this . source === 'string' && ( ! handleRegexp . test ( this . source ) && this . source . indexOf ( 'filestackcontent' ) === - 1 ) ) {
609
+ throw new FilestackError ( 'Invalid filestack source provided' ) ;
610
+ }
611
+ }
612
+
609
613
/**
610
614
* Returns JSONSchema form transformations params
611
615
*
@@ -1289,7 +1293,7 @@ export class Filelink {
1289
1293
continue ;
1290
1294
}
1291
1295
1292
- if ( toTest [ i ] . indexOf ( 'src:' ) === 0 || toTest [ i ] . indexOf ( 'http' ) === 0 ) {
1296
+ if ( toTest [ i ] . indexOf ( 'src:' ) === 0 || ( toTest [ i ] . indexOf ( 'http' ) === 0 && toTest [ i ] . indexOf ( 'filestackcontent' ) === - 1 ) ) {
1293
1297
return true ;
1294
1298
}
1295
1299
}
0 commit comments