Skip to content

Commit

Permalink
fix: added url check again
Browse files Browse the repository at this point in the history
  • Loading branch information
lem-onade committed Apr 16, 2020
1 parent 7dfbdcf commit 09cd485
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export class DGTSourceSolidValidator {
if (!url) {
throw new DGTErrorArgument('Passed url is null or undefined', url);
}
// Test if url is valid
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
const reg = /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i;
if (!reg.test(url)) {
this.logger.debug(DGTSourceSolidValidator.name, 'URL was not valid', url);
return false;
}
// Check headers for Link
this.http.head(url).subscribe(res => {
const headers = res.headers;
Expand Down

0 comments on commit 09cd485

Please sign in to comment.