Skip to content

Commit

Permalink
fix: repository URLs in style of 'git+http'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobak committed Jun 2, 2015
1 parent 9c57683 commit 1aefc5e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/pkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ exports.enhancePackage = function (pkg) {
repository.href = href;
} else if (repository.url.indexOf("http") === 0) {
repository.href = repository.url;
} else if (repository.url.indexOf("git+") === 0) {
href = repository.url.
replace("git+", "").
replace(".git", "/");
repository.href = href;
}
}
pkg.repository = repository;
Expand Down
34 changes: 33 additions & 1 deletion test/pkg-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe("pkg-test - getPackage", function () {
versions : {
"0.0.1" : {
name : "pkg",
version : "0,0.1"
version : "0.0.1"
}
}
};
Expand Down Expand Up @@ -1516,3 +1516,35 @@ describe('package npm functions', function () {
});
});
});


// ==== Test Case

describe("pkg-test - enhancePackage", function () {
var sandbox;

beforeEach(function () {
sandbox = sinon.sandbox.create();
});

afterEach(function () {
sandbox.restore();
});

it("should have function", function () {
assert.isFunction(pkg.enhancePackage);
});

it("should convert git+http", function () {
var pkgMeta = {
name : 'test',
repository : { url : 'git+https://github.com/test.git' },
versions : { "0.0.1" : { name : "pkg", version : "0.0.1" } },
"dist-tags" : { latest : "0.0.1" }
};

pkg.enhancePackage(pkgMeta);

assert.equal(pkgMeta.repository.href, 'https://github.com/test/');
});
});

0 comments on commit 1aefc5e

Please sign in to comment.