Skip to content

Commit

Permalink
Fix isNpmUrl to handle http/https urls (Closes #9236)
Browse files Browse the repository at this point in the history
  • Loading branch information
edi9999 authored and benjamn committed Nov 22, 2017
1 parent 03cc8d4 commit 16b74e5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -232,6 +232,7 @@
* iOS icons and launch screens have been updated to support iOS 11
[Issue #9196](https://github.com/meteor/meteor/issues/9196)
[PR #9198](https://github.com/meteor/meteor/pull/9198)
[Issue #9236] Allow Npm.depends to specify any http or https URL [#9236](https://github.com/meteor/meteor/issues/9236)

## v1.5.4, 2017-11-08

Expand Down
2 changes: 1 addition & 1 deletion tools/isobuild/package-npm.js
Expand Up @@ -24,7 +24,7 @@ export class PackageNpm {
* @param {Object} dependencies An object where the keys are package
* names and the values are one of:
* 1. Version numbers in string form
* 2. Http(s) URLs to a git commit by SHA.
* 2. Http(s) URLs to a npm package
* 3. Git URLs in the format described [here](https://docs.npmjs.com/files/package.json#git-urls-as-dependencies)
*
* Https URL example:
Expand Down
10 changes: 10 additions & 0 deletions tools/tests/utils-tests.js
Expand Up @@ -60,6 +60,16 @@ selftest.define("url has scheme", function () {
selftest.expectEqual(utils.hasScheme("example_com+http://"), false);
});


selftest.define("isNpmUrl", function () {
selftest.expectTrue(utils.isNpmUrl("https://github.com/caolan/async/archive/v2.3.0.tar.gz"));
selftest.expectTrue(utils.isNpmUrl("http://github.com/caolan/async/archive/v2.3.0.tar.gz"));
selftest.expectTrue(utils.isNpmUrl("git://github.com/foo/bar"));
selftest.expectTrue(utils.isNpmUrl("git+ssh://github.com/foo/bar"));
selftest.expectTrue(utils.isNpmUrl("git+http://github.com/foo/bar"));
selftest.expectTrue(utils.isNpmUrl("git+https://github.com/foo/bar"));
});

selftest.define("parse url", function () {
selftest.expectEqual(utils.parseUrl("http://localhost:3000"), {
hostname: "localhost",
Expand Down
2 changes: 1 addition & 1 deletion tools/utils/utils.js
Expand Up @@ -498,7 +498,7 @@ exports.isUrlWithSha = function (x) {
exports.isNpmUrl = function (x) {
// These are the various protocols that NPM supports, which we use to download NPM dependencies
// See https://docs.npmjs.com/files/package.json#git-urls-as-dependencies
return exports.isUrlWithSha(x) || /^(git|git\+ssh|git\+http|git\+https)?:\/\//.test(x);
return /^(git|git\+ssh|git\+http|git\+https|https|http)?:\/\//.test(x);
};

exports.isPathRelative = function (x) {
Expand Down

0 comments on commit 16b74e5

Please sign in to comment.