Skip to content

Commit 62b2c07

Browse files
authored
Merge pull request #770 from matrix-org/travis/fix-request
Manually construct query strings for browser-request instances
2 parents 11968a5 + 2fb29ae commit 62b2c07

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

browser-index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
var matrixcs = require("./lib/matrix");
2-
matrixcs.request(require("request"));
2+
const request = require('browser-request');
3+
const queryString = require('qs');
4+
5+
matrixcs.request(function(opts, fn) {
6+
// We manually fix the query string for browser-request because
7+
// it doesn't correctly handle cases like ?via=one&via=two. Instead
8+
// we mimic `request`'s query string interface to make it all work
9+
// as expected.
10+
// browser-request will happily take the constructed string as the
11+
// query string without trying to modify it further.
12+
opts.qs = queryString.stringify(opts.qs || {}, opts.qsStringifyOptions);
13+
return request(opts, fn);
14+
});
315

416
// just *accessing* indexedDB throws an exception in firefox with
517
// indexeddb disabled.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"content-type": "^1.0.2",
6060
"loglevel": "1.6.1",
6161
"memfs": "^2.10.1",
62+
"qs": "^6.5.2",
6263
"request": "^2.88.0"
6364
},
6465
"devDependencies": {

0 commit comments

Comments
 (0)