Browse Source

Removed 'qs' module dependency from ErrorDecoder

main
Brian Vaughn 7 years ago
parent
commit
d23c8c9aad
  1. 5
      flow-typed/qs.js
  2. 1
      package.json
  3. 24
      src/components/ErrorDecoder/ErrorDecoder.js
  4. 4
      yarn.lock

5
flow-typed/qs.js

@ -1,5 +0,0 @@
declare module 'qs' {
declare module.exports: {
parse: (str: string, opts: Object) => Object,
};
}

1
package.json

@ -50,7 +50,6 @@
"glamor": "^2.20.40", "glamor": "^2.20.40",
"hex2rgba": "^0.0.1", "hex2rgba": "^0.0.1",
"prettier": "^1.7.4", "prettier": "^1.7.4",
"qs": "^6.5.1",
"remarkable": "^1.7.1", "remarkable": "^1.7.1",
"request-promise": "^4.2.2", "request-promise": "^4.2.2",
"rimraf": "^2.6.1", "rimraf": "^2.6.1",

24
src/components/ErrorDecoder/ErrorDecoder.js

@ -8,7 +8,6 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import qs from 'qs';
import type {Node} from 'react'; import type {Node} from 'react';
@ -44,14 +43,25 @@ function urlify(str: string): Node {
function parseQueryString( function parseQueryString(
search: string, search: string,
): ?{|code: string, args: Array<string>|} { ): ?{|code: string, args: Array<string>|} {
const qsResult = qs.parse(search, {ignoreQueryPrefix: true}); const rawQueryString = search.substring(1);
if (!qsResult.invariant) { if (!rawQueryString) {
return null; return null;
} }
return {
code: qsResult.invariant, let code = '';
args: qsResult.args || [], let args = [];
};
const queries = rawQueryString.split('&');
for (let i = 0; i < queries.length; i++) {
const query = decodeURIComponent(queries[i]);
if (query.indexOf('invariant=') === 0) {
code = query.slice(10);
} else if (query.indexOf('args[') === 0) {
args.push(query.slice(query.indexOf(']=') + 2));
}
}
return {args, code};
} }
function ErrorResult(props: {|code: ?string, msg: string|}) { function ErrorResult(props: {|code: ?string, msg: string|}) {

4
yarn.lock

@ -7688,10 +7688,6 @@ qs@6.4.0, qs@~6.4.0:
version "6.4.0" version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
qs@^6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
query-string@^4.1.0: query-string@^4.1.0:
version "4.3.4" version "4.3.4"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb" resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb"

Loading…
Cancel
Save