pax_global_header 0000666 0000000 0000000 00000000064 13016436427 0014520 g ustar 00root root 0000000 0000000 52 comment=486ed80c20edb9cc3cc8accd4c020daa8431e1d2
node-github-url-from-git-1.5.0/ 0000775 0000000 0000000 00000000000 13016436427 0016252 5 ustar 00root root 0000000 0000000 node-github-url-from-git-1.5.0/.gitignore 0000664 0000000 0000000 00000000042 13016436427 0020236 0 ustar 00root root 0000000 0000000 node_modules
.nyc_output
coverage
node-github-url-from-git-1.5.0/CHANGELOG.md 0000664 0000000 0000000 00000001027 13016436427 0020063 0 ustar 00root root 0000000 0000000 # 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/LICENSE 0000664 0000000 0000000 00000002112 13016436427 0017253 0 ustar 00root root 0000000 0000000 (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/Makefile 0000664 0000000 0000000 00000000132 13016436427 0017706 0 ustar 00root root 0000000 0000000
test:
@./node_modules/.bin/mocha test.js --reporter spec --require should
.PHONY: test
node-github-url-from-git-1.5.0/Readme.md 0000664 0000000 0000000 00000006477 13016436427 0020007 0 ustar 00root root 0000000 0000000
# 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.js 0000664 0000000 0000000 00000001641 13016436427 0017721 0 ustar 00root root 0000000 0000000 // 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.json 0000664 0000000 0000000 00000001326 13016436427 0020542 0 ustar 00root root 0000000 0000000 {
"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.js 0000664 0000000 0000000 00000006571 13016436427 0017600 0 ustar 00root root 0000000 0000000 /* 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
)
})
})