Permalink
Browse files

passing tests

  • Loading branch information...
substack committed Dec 29, 2012
1 parent cc115f6 commit 2024555161c4ccda498b6079ec430bbd86a3564b
Showing with 52 additions and 3 deletions.
  1. +1 −1 example/url.js
  2. +2 −2 index.js
  3. +8 −0 test/a.json
  4. +5 −0 test/b.json
  5. +5 −0 test/c.json
  6. +7 −0 test/d.json
  7. +5 −0 test/e.json
  8. +19 −0 test/url.js
View
@@ -1,3 +1,3 @@
-var github = require('github-from-package');
+var github = require('../');
var url = github(require('./package.json'));
console.log(url);
View
@@ -10,8 +10,8 @@ module.exports = function (pkg) {
};
function match (str) {
- var m = /github.com[:\/]([^\/"]+)\/([^\/"]+)/.exec(str);
+ var m = /\bgithub.com[:\/]([^\/"]+)\/([^\/"]+)/.exec(str);
if (m) {
- return m[1] + '/' + m[2].replace(/\.git$/, '');
+ return 'https://github.com/' + m[1] + '/' + m[2].replace(/\.git$/, '');
}
}
View
@@ -0,0 +1,8 @@
+{
+ "name": "beep-boop",
+ "version": "1.2.3",
+ "repository" : {
+ "type" : "git",
+ "url": "git@github.com:substack/beep-boop.git"
+ }
+}
View
@@ -0,0 +1,5 @@
+{
+ "name": "beep-boop",
+ "version": "1.2.3",
+ "repository" : "git@github.com:substack/beep-boop.git"
+}
View
@@ -0,0 +1,5 @@
+{
+ "name": "beep-boop",
+ "version": "1.2.3",
+ "repository" : "https://github.com/substack/beep-boop.git"
+}
View
@@ -0,0 +1,7 @@
+{
+ "name": "beep-boop",
+ "version": "1.2.3",
+ "repository" : {
+ "url": "https://github.com/substack/beep-boop"
+ }
+}
View
@@ -0,0 +1,5 @@
+{
+ "name": "beep-boop",
+ "version": "1.2.3",
+ "homepage": "https://github.com/substack/beep-boop/issues"
+}
View
@@ -0,0 +1,19 @@
+var test = require('tape');
+var github = require('../');
+var packages = {
+ a : require('./a.json'),
+ b : require('./b.json'),
+ c : require('./c.json'),
+ d : require('./d.json'),
+ e : require('./e.json')
+};
+
+test(function (t) {
+ t.plan(5);
+ var url = 'https://github.com/substack/beep-boop';
+ t.equal(url, github(packages.a), 'a.json comparison');
+ t.equal(url, github(packages.b), 'b.json comparison');
+ t.equal(url, github(packages.c), 'c.json comparison');
+ t.equal(url, github(packages.d), 'd.json comparison');
+ t.equal(url, github(packages.e), 'e.json comparison');
+});

0 comments on commit 2024555

Please sign in to comment.