[Library | data-transfer-v2]: transferData.component.ts: Added class field "s3UrlRegex" and updated s3 regex to accept any url starting from s3://, https://, http://, www.

This commit is contained in:
Konstantina Galouni 2023-03-10 14:54:15 +02:00
parent e02ac38b7c
commit bb6707cc0d
1 changed files with 9 additions and 2 deletions

View File

@ -71,6 +71,11 @@ export class EGIDataTransferComponent {
jobId = null;
statusMessage = null;
jobStatus;
public s3UrlRegex = 's3:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' +
'[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|s3:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' +
'[a-zA-Z0-9]+\.[^\s]{2,}'
constructor(private http: HttpClient, private location: Location, private _router: Router, private cdr: ChangeDetectorRef) {
}
@ -476,7 +481,7 @@ export class EGIDataTransferComponent {
validateDestinationUrl():boolean {
if(this.selectedDestination.destination == "s3") {
return (this.destinationUrl.length > 0 && new RegExp('s3:\/\/[a-zA-Z0-9]+').test(this.destinationUrl));
return (this.destinationUrl.length > 0 && new RegExp("("+this.s3UrlRegex+")|("+StringUtils.urlRegex+")").test(this.destinationUrl));
}
return (this.destinationUrl.length > 0 && StringUtils.isValidUrl(this.destinationUrl));
}
@ -484,7 +489,9 @@ export class EGIDataTransferComponent {
public sourceUrlValidators() {
this.URLValidators = [];
if(this.selectedDestination.destination == 's3') {
this.URLValidators = [Validators.required, Validators.pattern('s3:\/\/[a-zA-Z0-9]+')];
this.URLValidators = [Validators.required, Validators.pattern("("+this.s3UrlRegex+")|("+StringUtils.urlRegex+")")];
// this.URLValidators = [Validators.required, Validators.pattern(this.s3UrlRegex) || StringUtils.urlValidator];
// this.URLValidators = [Validators.required, Validators.pattern(this.s3UrlRegex)];
} else {
this.URLValidators = [Validators.required, StringUtils.urlValidator()];
}