Skip to content

Commit 13373de

Browse files
committed
兼容新的只有 path 的 avatar
1 parent 37f97ff commit 13373de

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/js/common/utils.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,19 +334,22 @@ module.exports = {
334334
var matches = document.cookie.match("(^|;) ?" + encodeURIComponent(key) + "=([^;]*)(;|$)");
335335
return matches ? decodeURIComponent(matches[2]) : "";
336336
},
337+
// case1: /v1/tenants/5323/mediafiles/08d3d9bf-5507-4115-a6e6-1b50b0585f99MTAzZWQ2ZjUxNjczZmM2MjY2YmE4MGMyNDNhMGI1OWMucG5n/cutout?arg=114_0_305_305_300_300
337338
getAvatarsFullPath: function(url, domain){
338-
// 以前头像上传到阿里云的oss,那时阿里云的oss不支持https
339-
// 此处的逻辑是检测到阿里云的地址如果没有使用ossimages代理则加个代理
340-
// todo: 现在已经不使用这种逻辑了,但是为了兼容老数据所以没删除
341-
// 让运维洗一下数据,这部分逻辑就可以去掉了
342-
343-
if(!url) return;
344-
345-
url = url.replace(/^(https?:)?\/\/?/, "");
339+
// 阿里云的 oss 不支持 https,需要使用 ossimages 代理
340+
// 现在已经不使用这种逻辑了,但是为了兼容老数据所以没删除
341+
if(!url) return "";
342+
var hasProtocol = /^(https?:)?\/\//.test(url);
346343
var isKefuAvatar = ~url.indexOf("img-cn");
347344
var ossImg = ~url.indexOf("ossimages");
348-
349-
return isKefuAvatar && !ossImg ? domain + "/ossimages/" + url : "//" + url;
345+
url = url.replace(/^(https?:)?\/\/?/, "");
346+
if(isKefuAvatar && !ossImg){
347+
return domain + "/ossimages/" + url;
348+
}
349+
else if(!hasProtocol){
350+
return domain + "/" + url;
351+
}
352+
return "//" + url;
350353
},
351354
copy: function(obj){
352355
// todo:移到,easemob.js 里边

0 commit comments

Comments
 (0)