Skip to content

Commit d23c8c9

Browse files
committed
Removed 'qs' module dependency from ErrorDecoder
1 parent 5cc6028 commit d23c8c9

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

flow-typed/qs.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"glamor": "^2.20.40",
5151
"hex2rgba": "^0.0.1",
5252
"prettier": "^1.7.4",
53-
"qs": "^6.5.1",
5453
"remarkable": "^1.7.1",
5554
"request-promise": "^4.2.2",
5655
"rimraf": "^2.6.1",

src/components/ErrorDecoder/ErrorDecoder.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
'use strict';
99

1010
import React from 'react';
11-
import qs from 'qs';
1211

1312
import type {Node} from 'react';
1413

@@ -44,14 +43,25 @@ function urlify(str: string): Node {
4443
function parseQueryString(
4544
search: string,
4645
): ?{|code: string, args: Array<string>|} {
47-
const qsResult = qs.parse(search, {ignoreQueryPrefix: true});
48-
if (!qsResult.invariant) {
46+
const rawQueryString = search.substring(1);
47+
if (!rawQueryString) {
4948
return null;
5049
}
51-
return {
52-
code: qsResult.invariant,
53-
args: qsResult.args || [],
54-
};
50+
51+
let code = '';
52+
let args = [];
53+
54+
const queries = rawQueryString.split('&');
55+
for (let i = 0; i < queries.length; i++) {
56+
const query = decodeURIComponent(queries[i]);
57+
if (query.indexOf('invariant=') === 0) {
58+
code = query.slice(10);
59+
} else if (query.indexOf('args[') === 0) {
60+
args.push(query.slice(query.indexOf(']=') + 2));
61+
}
62+
}
63+
64+
return {args, code};
5565
}
5666

5767
function ErrorResult(props: {|code: ?string, msg: string|}) {

yarn.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7688,10 +7688,6 @@ qs@6.4.0, qs@~6.4.0:
76887688
version "6.4.0"
76897689
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
76907690

7691-
qs@^6.5.1:
7692-
version "6.5.1"
7693-
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
7694-
76957691
query-string@^4.1.0:
76967692
version "4.3.4"
76977693
resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb"

0 commit comments

Comments
 (0)