pax_global_header00006660000000000000000000000064130164364270014520gustar00rootroot0000000000000052 comment=486ed80c20edb9cc3cc8accd4c020daa8431e1d2 node-github-url-from-git-1.5.0/000077500000000000000000000000001301643642700162525ustar00rootroot00000000000000node-github-url-from-git-1.5.0/.gitignore000066400000000000000000000000421301643642700202360ustar00rootroot00000000000000node_modules .nyc_output coverage node-github-url-from-git-1.5.0/CHANGELOG.md000066400000000000000000000010271301643642700200630ustar00rootroot00000000000000# Change Log All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. # [1.5.0](https://github.com/visionmedia/node-github-url-from-git/compare/v1.4.0...v1.5.0) (2016-11-27) ### Features * support paths starting with / in git@ urls ([#20](https://github.com/visionmedia/node-github-url-from-git/issues/20)) ([0e99827](https://github.com/visionmedia/node-github-url-from-git/commit/0e99827)) node-github-url-from-git-1.5.0/LICENSE000066400000000000000000000021121301643642700172530ustar00rootroot00000000000000(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.5.0/Makefile000066400000000000000000000001321301643642700177060ustar00rootroot00000000000000 test: @./node_modules/.bin/mocha test.js --reporter spec --require should .PHONY: test node-github-url-from-git-1.5.0/Readme.md000066400000000000000000000064771301643642700200070ustar00rootroot00000000000000 # 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(parse(url) == null) }) 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', 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 ) }) }) ``` node-github-url-from-git-1.5.0/index.js000066400000000000000000000016411301643642700177210ustar00rootroot00000000000000// 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.5.0/package.json000066400000000000000000000013261301643642700205420ustar00rootroot00000000000000{ "name": "github-url-from-git", "version": "1.5.0", "description": "Parse a github git url and return the github repo url", "main": "index.js", "scripts": { "pretest": "standard", "test": "nyc mocha test.js --reporter spec --require should", "release": "standard-version" }, "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.2", "mocha": "^3.2.0", "nyc": "^10.0.0", "should": "^11.1.1", "standard": "^8.6.0", "standard-version": "^4.0.0-1" } } node-github-url-from-git-1.5.0/test.js000066400000000000000000000065711301643642700176000ustar00rootroot00000000000000/* global describe, it */ var 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(parse(url) == null) }) 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', 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 ) }) })