diff --git a/sheep/helper/tools.js b/sheep/helper/tools.js index 49efcecb..8712917e 100644 --- a/sheep/helper/tools.js +++ b/sheep/helper/tools.js @@ -19,15 +19,19 @@ export default { * @param {String} url -图片地址 */ checkMPUrl(url) { + if (!url || typeof url !== 'string') { + return url; + } + // #ifdef MP if ( - url.substring(0, 4) === 'http' && - url.substring(0, 5) !== 'https' && - url.substring(0, 12) !== 'http://store' && - url.substring(0, 10) !== 'http://tmp' && - url.substring(0, 10) !== 'http://usr' + url.startsWith('http://') && + !url.startsWith('https://') && + !url.startsWith('http://store') && + !url.startsWith('http://tmp') && + !url.startsWith('http://usr') ) { - url = 'https' + url.substring(4, url.length); + url = url.replace('http://', 'https://'); } // #endif return url;