Skip to content

Commit 7b52049

Browse files
committed
refactor: replace query-string with URLSearchParams
1 parent d9960de commit 7b52049

File tree

4 files changed

+20
-83
lines changed

4 files changed

+20
-83
lines changed

package-lock.json

Lines changed: 8 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"prismjs": "1.25.0",
6363
"prop-types": "15.7.2",
6464
"qrcode": "1.4.4",
65-
"query-string": "6.14.1",
6665
"react": "16.14.0",
6766
"react-ace": "9.4.3",
6867
"react-dnd": "10.0.2",

src/dashboard/Data/Browser/Browser.react.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import stringCompare from 'lib/stringCompare';
3434
import styles from 'dashboard/Data/Browser/Browser.scss';
3535
import subscribeTo from 'lib/subscribeTo';
3636
import * as ColumnPreferences from 'lib/ColumnPreferences';
37-
import * as queryString from 'query-string';
3837
import { Helmet } from 'react-helmet';
3938
import PropTypes from 'lib/PropTypes';
4039
import ParseApp from 'lib/ParseApp';
@@ -213,9 +212,9 @@ class Browser extends DashboardView {
213212
if (!props || !props.location || !props.location.search) {
214213
return filters;
215214
}
216-
const query = queryString.parse(props.location.search);
217-
if (query.filters) {
218-
const queryFilters = JSON.parse(query.filters);
215+
const query = new URLSearchParams(props.location.search);
216+
if (query.has('filters')) {
217+
const queryFilters = JSON.parse(query.get('filters'));
219218
queryFilters.forEach((filter) => filters = filters.push(new Map(filter)));
220219
}
221220
return filters;
@@ -397,7 +396,7 @@ class Browser extends DashboardView {
397396
if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) {
398397
return;
399398
}
400-
if (!!required) {
399+
if (required) {
401400
requiredCols.push(name);
402401
}
403402
if (className === '_User' && (name === 'username' || name === 'password')) {
@@ -414,7 +413,7 @@ class Browser extends DashboardView {
414413
for (let idx = 0; idx < requiredCols.length; idx++) {
415414
const name = requiredCols[idx];
416415
if (!obj.get(name)) {
417-
this.showNote("Please enter all required fields", true);
416+
this.showNote('Please enter all required fields', true);
418417
this.setState({
419418
markRequiredFieldRow: -1
420419
});
@@ -452,7 +451,7 @@ class Browser extends DashboardView {
452451
});
453452
},
454453
error => {
455-
let msg = typeof error === "string" ? error : error.message;
454+
let msg = typeof error === 'string' ? error : error.message;
456455
if (msg) {
457456
msg = msg[0].toUpperCase() + msg.substr(1);
458457
}
@@ -472,7 +471,7 @@ class Browser extends DashboardView {
472471
this.setState(state);
473472
},
474473
error => {
475-
let msg = typeof error === "string" ? error : error.message;
474+
let msg = typeof error === 'string' ? error : error.message;
476475
if (msg) {
477476
msg = msg[0].toUpperCase() + msg.substr(1);
478477
}
@@ -501,7 +500,7 @@ class Browser extends DashboardView {
501500
if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) {
502501
return;
503502
}
504-
if (!!required) {
503+
if (required) {
505504
requiredCols.push(name);
506505
}
507506
if (className === '_User' && (name === 'username' || name === 'password')) {
@@ -518,7 +517,7 @@ class Browser extends DashboardView {
518517
for (let idx = 0; idx < requiredCols.length; idx++) {
519518
const name = requiredCols[idx];
520519
if (!obj.get(name)) {
521-
this.showNote("Please enter all required fields", true);
520+
this.showNote('Please enter all required fields', true);
522521
this.setState({
523522
markRequiredFieldRow: rowIndex
524523
});

src/dashboard/Push/PushNew.react.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import Toggle from 'components/Toggle/Toggle.react';
3636
import Toolbar from 'components/Toolbar/Toolbar.react';
3737
import { Directions } from 'lib/Constants';
3838
import { extractExpiration, extractPushTime } from 'lib/extractTime';
39-
import * as queryString from 'query-string';
4039

4140
const PARSE_SERVER_SUPPORTS_AB_TESTING = false;
4241

@@ -148,11 +147,11 @@ class PushNew extends DashboardView {
148147
componentWillMount() {
149148
this.props.schema.dispatch(SchemaStore.ActionTypes.FETCH);
150149
let options = { xhrKey: XHR_KEY };
151-
const query = queryString.parse(this.props.location.search);
152-
if (query.audienceId) {
150+
const query = new URLSearchParams(this.props.location.search);
151+
if (query.has('audienceId')) {
153152
options.limit = PushConstants.SHOW_MORE_LIMIT;
154153
options.min = PushConstants.INITIAL_PAGE_SIZE;
155-
this.setState({ initialAudienceId: query.audienceId });
154+
this.setState({ initialAudienceId: query.get('audienceId') });
156155
}
157156
this.props.pushaudiences.dispatch(PushAudiencesStore.ActionTypes.FETCH,
158157
options).then(() => {

0 commit comments

Comments
 (0)