Skip to content

Commit

Permalink
fix: isRemoteUrl check improved to reduce false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudinary-pkoniu committed May 2, 2023
1 parent aaaf45f commit 19ebc84
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib-es5/utils/isRemoteUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var isString = require('lodash/isString');
* @returns {boolean} true if the given url is a remote location or data
*/
function isRemoteUrl(url) {
return isString(url) && /^ftp:|^https?:|^gs:|^s3:|^data:/.test(url);
var SUBSTRING_LENGTH = 120;
var urlSubstring = url.substring(0, SUBSTRING_LENGTH);
return isString(url) && /^ftp:|^https?:|^gs:|^s3:|^data:([\w-.]+\/[\w-.]+(\+[\w-.]+)?)?(;[\w-.]+=[\w-.]+)*;base64,([a-zA-Z0-9\/+\n=]+)$/.test(urlSubstring);
}

module.exports = isRemoteUrl;

0 comments on commit 19ebc84

Please sign in to comment.