node/deps/npm/node_modules/github-url-from-username-repo/index.js

13 lines
245 B
JavaScript

module.exports = getUrl
function getUrl (r, forBrowser) {
if (!r) return null
if (/^[\w-]+\/[\w\.-]+(#[a-z0-9]*)?$/.test(r)) {
if (forBrowser)
r = r.replace("#", "/tree/")
return "https://github.com/" + r
}
return null
}