]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/github-url-from-username-repo/index.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / github-url-from-username-repo / index.js
1 module.exports = getUrl
2
3 function getUrl (r, forBrowser) {
4   if (!r) return null
5   // Regex taken from https://github.com/npm/npm-package-arg/commit/01dce583c64afae07b66a2a8a6033aeba871c3cd
6   // Note: This does not fully test the git ref format.
7   // See https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
8   //
9   // The only way to do this properly would be to shell out to
10   // git-check-ref-format, and as this is a fast sync function,
11   // we don't want to do that. Just let git fail if it turns
12   // out that the commit-ish is invalid.
13   // GH usernames cannot start with . or -
14   if (/^[^@%\/\s\.-][^:@%\/\s]*\/[^@\s\/%]+(?:#.*)?$/.test(r)) {
15     if (forBrowser)
16       r = r.replace("#", "/tree/")
17     return "https://github.com/" + r
18   }
19
20   return null
21 }