pax_global_header00006660000000000000000000000064123754305030014514gustar00rootroot0000000000000052 comment=154df00b0b590c29be5d2a5822e7b2e160b75345 node-github-url-from-git-1.4.0/000077500000000000000000000000001237543050300162455ustar00rootroot00000000000000node-github-url-from-git-1.4.0/.gitignore000066400000000000000000000000151237543050300202310ustar00rootroot00000000000000node_modules node-github-url-from-git-1.4.0/LICENSE000066400000000000000000000021121237543050300172460ustar00rootroot00000000000000(The MIT License) Copyright (c) 2013 TJ Holowaychuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-github-url-from-git-1.4.0/Makefile000066400000000000000000000001321237543050300177010ustar00rootroot00000000000000 test: @./node_modules/.bin/mocha test.js --reporter spec --require should .PHONY: test node-github-url-from-git-1.4.0/Readme.md000066400000000000000000000061561237543050300177740ustar00rootroot00000000000000 # github-url-from-git ```js describe('parse(url)', function(){ it('should support git://*', function(){ var url = 'git://github.com/jamesor/mongoose-versioner'; parse(url).should.equal('https://github.com/jamesor/mongoose-versioner'); }) it('should support git://*.git', function(){ var url = 'git://github.com/treygriffith/cellar.git'; parse(url).should.equal('https://github.com/treygriffith/cellar'); }) it('should support https://*', function(){ var url = 'https://github.com/Empeeric/i18n-node'; parse(url).should.equal('https://github.com/Empeeric/i18n-node'); }) it('should support https://*.git', function(){ var url = 'https://jpillora@github.com/banchee/tranquil.git'; parse(url).should.equal('https://github.com/banchee/tranquil'); }) it('should return undefined on failure', function(){ var url = 'git://github.com/justgord/.git'; assert(null == parse(url)); }) it('should parse git@github.com:bcoe/thumbd.git', function() { var url = 'git@github.com:bcoe/thumbd.git'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse git@github.com:bcoe/thumbd.git#2.7.0', function() { var url = 'git@github.com:bcoe/thumbd.git#2.7.0'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse git+https://github.com/bcoe/thumbd.git', function() { var url = 'git+https://github.com/bcoe/thumbd.git'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse git+ssh://github.com/bcoe/thumbd.git', function() { var url = 'git+ssh://github.com/bcoe/thumbd.git'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse https://EastCloud@github.com/EastCloud/node-websockets.git', function() { var url = 'https://EastCloud@github.com/EastCloud/node-websockets.git'; parse(url).should.eql('https://github.com/EastCloud/node-websockets'); }) // gist urls. it('should parse git@gist urls', function() { var url = 'git@gist.github.com:3135914.git'; parse(url).should.equal('https://gist.github.com/3135914') }) it('should parse https://gist urls', function() { var url = 'https://gist.github.com/3135914.git'; parse(url).should.equal('https://gist.github.com/3135914') }) // Handle arbitrary GitHub Enterprise domains. it('should parse parse extra GHE urls provided', function() { var url = 'git://github.example.com/treygriffith/cellar.git'; parse( url, {extraBaseUrls: ['github.example.com']} ).should.equal('https://github.example.com/treygriffith/cellar'); }); it('should parse GHE urls with multiple subdomains', function() { var url = 'git://github.internal.example.com/treygriffith/cellar.git'; parse( url, {extraBaseUrls: ['github.internal.example.com']} ).should.equal('https://github.internal.example.com/treygriffith/cellar'); }); }) describe('re', function() { it('should expose GitHub url parsing regex', function() { parse.re.source.should.equal( /^(?:https?:\/\/|git:\/\/)?(?:[^@]+@)?(gist.github.com|github.com)[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/.source ) }); }) ``` node-github-url-from-git-1.4.0/index.js000066400000000000000000000016431237543050300177160ustar00rootroot00000000000000// convert git:// form url to github URL, e.g., // git://github.com/bcoe/foo.git // https://github.com/bcoe/foo. function githubUrlFromGit(url, opts){ try { var m = re(opts).exec(url.replace(/\.git(#.*)?$/, '')); var host = m[1]; var path = m[2]; return 'https://' + host + '/' + path; } catch (err) { // ignore } }; // generate the git:// parsing regex // with options, e.g., the ability // to specify multiple GHE domains. function re(opts) { opts = opts || {}; // whitelist of URLs that should be treated as GitHub repos. var baseUrls = ['gist.github.com', 'github.com'].concat(opts.extraBaseUrls || []); // build regex from whitelist. return new RegExp( /^(?:https?:\/\/|git:\/\/|git\+ssh:\/\/|git\+https:\/\/)?(?:[^@]+@)?/.source + '(' + baseUrls.join('|') + ')' + /[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/.source ); } githubUrlFromGit.re = re(); module.exports = githubUrlFromGit; node-github-url-from-git-1.4.0/package.json000066400000000000000000000010771237543050300205400ustar00rootroot00000000000000{ "name": "github-url-from-git", "version": "1.4.0", "description": "Parse a github git url and return the github repo url", "main": "index.js", "scripts": { "test": "mocha test.js --reporter spec --require should" }, "repository": { "type": "git", "url": "https://github.com/visionmedia/node-github-url-from-git.git" }, "keywords": [ "github", "git", "url", "parser" ], "author": "TJ Holowaychuk", "license": "MIT", "devDependencies": { "better-assert": "~1.0.0", "mocha": "~1.9.0", "should": "~1.2.2" } } node-github-url-from-git-1.4.0/test.js000066400000000000000000000062551237543050300175720ustar00rootroot00000000000000var parse = require('./'); var assert = require('better-assert'); describe('parse(url)', function(){ it('should support git://*', function(){ var url = 'git://github.com/jamesor/mongoose-versioner'; parse(url).should.equal('https://github.com/jamesor/mongoose-versioner'); }) it('should support git://*.git', function(){ var url = 'git://github.com/treygriffith/cellar.git'; parse(url).should.equal('https://github.com/treygriffith/cellar'); }) it('should support https://*', function(){ var url = 'https://github.com/Empeeric/i18n-node'; parse(url).should.equal('https://github.com/Empeeric/i18n-node'); }) it('should support https://*.git', function(){ var url = 'https://jpillora@github.com/banchee/tranquil.git'; parse(url).should.equal('https://github.com/banchee/tranquil'); }) it('should return undefined on failure', function(){ var url = 'git://github.com/justgord/.git'; assert(null == parse(url)); }) it('should parse git@github.com:bcoe/thumbd.git', function() { var url = 'git@github.com:bcoe/thumbd.git'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse git@github.com:bcoe/thumbd.git#2.7.0', function() { var url = 'git@github.com:bcoe/thumbd.git#2.7.0'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse git+https://github.com/bcoe/thumbd.git', function() { var url = 'git+https://github.com/bcoe/thumbd.git'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse git+ssh://github.com/bcoe/thumbd.git', function() { var url = 'git+ssh://github.com/bcoe/thumbd.git'; parse(url).should.eql('https://github.com/bcoe/thumbd'); }) it('should parse https://EastCloud@github.com/EastCloud/node-websockets.git', function() { var url = 'https://EastCloud@github.com/EastCloud/node-websockets.git'; parse(url).should.eql('https://github.com/EastCloud/node-websockets'); }) // gist urls. it('should parse git@gist urls', function() { var url = 'git@gist.github.com:3135914.git'; parse(url).should.equal('https://gist.github.com/3135914') }) it('should parse https://gist urls', function() { var url = 'https://gist.github.com/3135914.git'; parse(url).should.equal('https://gist.github.com/3135914') }) // Handle arbitrary GitHub Enterprise domains. it('should parse parse extra GHE urls provided', function() { var url = 'git://github.example.com/treygriffith/cellar.git'; parse( url, {extraBaseUrls: ['github.example.com']} ).should.equal('https://github.example.com/treygriffith/cellar'); }); it('should parse GHE urls with multiple subdomains', function() { var url = 'git://github.internal.example.com/treygriffith/cellar.git'; parse( url, {extraBaseUrls: ['github.internal.example.com']} ).should.equal('https://github.internal.example.com/treygriffith/cellar'); }); }) describe('re', function() { it('should expose GitHub url parsing regex', function() { parse.re.source.should.equal( /^(?:https?:\/\/|git:\/\/|git\+ssh:\/\/|git\+https:\/\/)?(?:[^@]+@)?(gist.github.com|github.com)[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/.source ) }); })