From bb6707cc0d8486226415781861078ed0f67e2f28 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 10 Mar 2023 14:54:15 +0200 Subject: [PATCH] [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. --- utils/dataTransfer/transferData.component.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/dataTransfer/transferData.component.ts b/utils/dataTransfer/transferData.component.ts index 2e979f7f..bb53b68e 100644 --- a/utils/dataTransfer/transferData.component.ts +++ b/utils/dataTransfer/transferData.component.ts @@ -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()]; }