diff --git a/browser-index.js b/browser-index.js index 32b62640cb9..cc7e50fe811 100644 --- a/browser-index.js +++ b/browser-index.js @@ -1,5 +1,17 @@ var matrixcs = require("./lib/matrix"); -matrixcs.request(require("request")); +const request = require('browser-request'); +const queryString = require('qs'); + +matrixcs.request(function(opts, fn) { + // We manually fix the query string for browser-request because + // it doesn't correctly handle cases like ?via=one&via=two. Instead + // we mimic `request`'s query string interface to make it all work + // as expected. + // browser-request will happily take the constructed string as the + // query string without trying to modify it further. + opts.qs = queryString.stringify(opts.qs || {}, opts.qsStringifyOptions); + return request(opts, fn); +}); // just *accessing* indexedDB throws an exception in firefox with // indexeddb disabled. diff --git a/package.json b/package.json index 5dfc84c943c..26608e1e22f 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "content-type": "^1.0.2", "loglevel": "1.6.1", "memfs": "^2.10.1", + "qs": "^6.5.2", "request": "^2.88.0" }, "devDependencies": {