UNPKG

ja

Version:

A simple CLI to read files from git repositories

17 lines (12 loc) 362 B
const { URL } = require('url') function whereFrom(source) { const ret = new URL(source) if (ret.host === 'github.com') { ret.host = 'raw.githubusercontent.com' } else if (!ret.host.startsWith('raw.')) { ret.host = 'raw.' + ret.host } ret.pathname = ret.pathname.replace('blob/', '') return ret.toString() } module.exports = { whereFrom }