获取图片地址url的后缀名

getNameFromLink(url){

     if(url.indexOf('.cn/') !== -1){
          return (url.split('.')[url.split('.').length - 2] + '.' + url.split('.')[url.split('.').length - 1]).substring(3)
     }else if(url.indexOf('.com/') !== -1){
          return (url.split('.')[url.split('.').length - 2] + '.' + url.split('.')[url.split('.').length - 1]).substring(4)
     }


},

let links = getNameFromLink('https://csdnimg.cn/pubfooter/images/job-QR.png')
console.log(links)   //  pubfooter/images/job-QR.png

 

 

posted @ 2019-05-28 15:37  Panax  阅读(1290)  评论(0编辑  收藏  举报