/** * common 相关 utils * @author: 刘传洋<chuanyang.liu@yoho.cn> * @date: 2016/10/31 */ /** * 01=["img10.static.yhbimg.com", "img11.static.yhbimg.com"], * 02=["img12.static.yhbimg.com", "img13.static.yhbimg.com"] * 03=["flv01.static.yhbimg.com", "flv01.static.yhbimg.com"] * @param url * @param bucket * @returns {*} */ 'use strict'; const getUploadImgAbsoluteUrl = (url, bucket) => { if (!url) { return null; } let urlArr = url.split('/'), stag = urlArr[urlArr.length - 1].substr(0, 2), domain = `static.yhbimg.com/${bucket}`; url = domain + url; if (stag === '01') { return `//img11.${url}`; } else if (stag === '03') { return `//flv01.${url}`; } else { return `//img12.${url}`; } }; module.exports = { getUploadImgAbsoluteUrl };