diff --git a/modules/PathUtils.js b/modules/PathUtils.js index b585d3baa4..532d3442ea 100644 --- a/modules/PathUtils.js +++ b/modules/PathUtils.js @@ -1,5 +1,5 @@ var invariant = require('react/lib/invariant'); -var merge = require('qs/lib/utils').merge; +var objectAssign = require('object-assign'); var qs = require('qs'); var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g; @@ -144,14 +144,14 @@ var PathUtils = { var existingQuery = PathUtils.extractQuery(path); if (existingQuery) - query = query ? merge(existingQuery, query) : existingQuery; + query = query ? objectAssign(existingQuery, query) : existingQuery; var queryString = qs.stringify(query, { arrayFormat: 'brackets' }); if (queryString) return PathUtils.withoutQuery(path) + '?' + queryString; - return path; + return Path.withoutQuery(path); } }; diff --git a/modules/__tests__/PathUtils-test.js b/modules/__tests__/PathUtils-test.js index 02f6d682d0..a56f457194 100644 --- a/modules/__tests__/PathUtils-test.js +++ b/modules/__tests__/PathUtils-test.js @@ -319,6 +319,10 @@ describe('PathUtils.withQuery', function () { expect(PathUtils.withQuery('/path?a=b', { c: [ 'd', 'e' ] })).toEqual('/path?a=b&c%5B%5D=d&c%5B%5D=e'); }); + it('removes query string', function () { + expect(Path.withQuery('/a/b/c?a=b', { a: undefined })).toEqual('/a/b/c'); + }); + it('handles special characters', function () { expect(PathUtils.withQuery('/path?a=b', { c: [ 'd#e', 'f&a=i#j+k' ] })).toEqual('/path?a=b&c%5B%5D=d%23e&c%5B%5D=f%26a%3Di%23j%2Bk'); }); diff --git a/package.json b/package.json index 3908fa6d84..b92f3423bd 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,8 @@ }, "dependencies": { "qs": "2.4.1", - "classnames": "1.1.x" + "classnames": "1.1.x", + "object-assign": "^2.0.0" }, "tags": [ "react",