Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github-url-parse

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-url-parse - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

1

gulpfile.js

@@ -16,2 +16,3 @@ 'use strict';

.pipe(plugins.jshint('.jshintrc'))
.pipe(plugins.plumber())
.pipe(plugins.jscs())

@@ -18,0 +19,0 @@ .pipe(plugins.jshint.reporter('jshint-stylish'));

@@ -11,4 +11,30 @@ /*

exports.awesome = function() {
return 'awesome';
var url = require('url');
var GITHUBCOM = 'github.com';
module.exports = function(githubURL) {
var o = url.parse( githubURL );
if (o.host !== GITHUBCOM) {
return null;
}
var paths = url.parse(o).path.split('/').filter(Boolean);
var result = {};
var keys = ['user', 'repo', 'type', 'branch'];
paths.forEach(function(item, index) {
var k = keys[index];
if (k) {
result[k] = item;
}
});
if (paths.length > keys.length) {
result.path = paths.slice(keys.length).join('/');
}
return result;
};

10

package.json
{
"name": "github-url-parse",
"description": "Parse a GitHub url",
"version": "0.0.0",
"description": "Parse the github user, repo, branch and other things from a GitHub url.",
"version": "0.1.0",
"homepage": "https://github.com/stefanbuck/github-url-parse",

@@ -19,7 +19,3 @@ "bugs": "https://github.com/stefanbuck/github-url-parse/issues",

"keywords":[],
"dependencies": {
"lodash": "2.4.1",
"q": "2.0.2",
"debug": "1.0.2"
},
"dependencies": {},
"devDependencies": {

@@ -26,0 +22,0 @@ "gulp": "^3.6.2",

# github-url-parse
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image] [![Coverage Status][coveralls-image]][coveralls-url]
Parse a GitHub url
Parse the github user, repo, branch and other things from a GitHub url.

@@ -17,21 +17,14 @@

```javascript
var githubUrlParse = require('github-url-parse');
githubUrlParse.awesome(); // "awesome"
```
var gitHubUrlParse = require('github-url-parse');
## API
var github = gitHubUrlParse('https://github.com/stefanbuck/github-url-parse/blob/master/lib/index.js');
_(Coming soon)_
console.log('user:' + github.user); // stefanbuck
console.log('repo:' + github.repo); // github-url-parse
console.log('branch:' + github.branch); // master
console.log('path:' + github.path); // lib/index.js
console.log('type:' + github.type); // blob
```
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [gulp](http://gulpjs.com/).
## Release History
_(Nothing yet)_
## License

@@ -38,0 +31,0 @@

@@ -8,6 +8,59 @@ 'use strict';

it('should be awesome', function () {
githubUrlParse.awesome().should.equal('awesome');
it('with google.com', function () {
assert.equal(githubUrlParse('http://google.com', null));
});
it('with github.com', function () {
assert.notEqual(githubUrlParse('http://github.com', null));
});
it('with username', function () {
githubUrlParse('http://github.com/stefanbuck').should.eql({
user:'stefanbuck'
});
});
it('with repo', function () {
githubUrlParse('http://github.com/stefanbuck/github-url-parse').should.eql({
user:'stefanbuck',
repo: 'github-url-parse'
});
});
it('with type', function () {
githubUrlParse('http://github.com/stefanbuck/github-url-parse/tree').should.eql({
user:'stefanbuck',
repo: 'github-url-parse',
type: 'tree'
});
});
it('with branch', function () {
githubUrlParse('http://github.com/stefanbuck/github-url-parse/tree/master').should.eql({
user:'stefanbuck',
repo: 'github-url-parse',
branch: 'master',
type: 'tree'
});
});
it('with path', function () {
githubUrlParse('http://github.com/stefanbuck/github-url-parse/tree/master/lib/utils').should.eql({
user:'stefanbuck',
repo: 'github-url-parse',
branch: 'master',
path: 'lib/utils',
type: 'tree'
});
});
it('with file file', function () {
githubUrlParse('https://github.com/stefanbuck/github-url-parse/blob/master/lib/index.js').should.eql({
user:'stefanbuck',
repo: 'github-url-parse',
branch: 'master',
path: 'lib/index.js',
type: 'blob'
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc