Skip to content

Commit

Permalink
Merge pull request #770 from matrix-org/travis/fix-request
Browse files Browse the repository at this point in the history
Manually construct query strings for browser-request instances
  • Loading branch information
turt2live authored Oct 30, 2018
2 parents 11968a5 + 2fb29ae commit 62b2c07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion browser-index.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 62b2c07

Please sign in to comment.