Skip to content

Commit

Permalink
fix: taking substring only if input is a string
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudinary-pkoniu committed May 2, 2023
1 parent d862be8 commit b9d8266
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/isRemoteUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const isString = require('lodash/isString');
*/
function isRemoteUrl(url) {
const SUBSTRING_LENGTH = 120;
const urlSubstring = url.substring(0, SUBSTRING_LENGTH);
const urlSubstring = isString(url) && 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);
}

Expand Down

0 comments on commit b9d8266

Please sign in to comment.