Skip to content

Commit b64d8bf

Browse files
committed
Merge pull request bower#912 from beardtwizzle/master
Allow for existence of query-string parameters in URL
2 parents b41c8ad + 7a50116 commit b64d8bf

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/core/resolvers/UrlResolver.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ UrlResolver.prototype._resolve = function () {
105105
// -----------------
106106

107107
UrlResolver.prototype._download = function () {
108-
var file = path.join(this._tempDir, path.basename(this._source));
108+
var fileName = url.parse(path.basename(this._source)).pathname;
109+
var file = path.join(this._tempDir, fileName);
109110
var reqHeaders = {};
110111
var that = this;
111112

test/core/resolvers/urlResolver.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,32 @@ describe('UrlResolver', function () {
568568
.done();
569569
});
570570

571+
it('should allow for query strings in URL', function (next) {
572+
var resolver;
573+
574+
nock('http://bower.io')
575+
.get('/foo.js?bar=baz')
576+
.reply(200, 'foo contents');
577+
578+
resolver = create('http://bower.io/foo.js?bar=baz');
579+
580+
resolver.resolve()
581+
.then(function (dir) {
582+
var contents;
583+
584+
expect(fs.existsSync(path.join(dir, 'index.js'))).to.be(true);
585+
expect(fs.existsSync(path.join(dir, 'foo.js'))).to.be(false);
586+
expect(fs.existsSync(path.join(dir, 'foo.js?bar=baz'))).to.be(false);
587+
588+
contents = fs.readFileSync(path.join(dir, 'index.js')).toString();
589+
expect(contents).to.equal('foo contents');
590+
591+
assertMain(dir, 'index.js')
592+
.then(next.bind(next, null));
593+
})
594+
.done();
595+
});
596+
571597
it('should save cache headers', function (next) {
572598
var resolver;
573599

0 commit comments

Comments
 (0)