const getInfo = str => { let s = str || document.getElementById('like-water').getAttribute('data-file'); s = s.replace('https://raw.githubusercontent.com/', ''); s = s.replace('.json', ''); s = s.replace('.html', ''); const json = 'https://raw.githubusercontent.com/' + s + '.json'; s = s.split('/'); return { owner: s.shift(), repo: s.shift(), branch: s.shift(), path: s.join('/'), json }; }; export default getInfo;