mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix(cli): replace querystring with URLSearchParam (#45125)
Summary: [`querystring`](https://www.npmjs.com/package/querystring) package is deprecated. In this Pull Request I've replaced usage of `querystring` with `URLSearchParam` what is recommended by Node.js. It's also causing a warning when installing dependencies inside a React Native app: ``` warning react-native > react-native/community-cli-plugin > querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. ``` ## Changelog: [INTERNAL] [FIXED] - Replace `querystring` package with `URLSearchParam` Pull Request resolved: https://github.com/facebook/react-native/pull/45125 Test Plan: Params should be parsed in the same way and warning shouldn't be presented. js1 jest xplat/js/tools/metro/packages/metro/src/cli/__tests__/parseKeyValueParamArray-test.js Reviewed By: cipolleschi Differential Revision: D58948498 Pulled By: GijsWeterings fbshipit-source-id: 79b1f7b3feae230d2d3641205c513b98b3fda511
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b34b694f8e
commit
d1bf828398
@@ -9,8 +9,6 @@
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
import querystring from 'querystring';
|
||||
|
||||
export default function parseKeyValueParamArray(
|
||||
keyValueArray: $ReadOnlyArray<string>,
|
||||
): Record<string, string> {
|
||||
@@ -23,8 +21,11 @@ export default function parseKeyValueParamArray(
|
||||
if (item.indexOf('&') !== -1) {
|
||||
throw new Error('Parameter cannot include "&" but found: ' + item);
|
||||
}
|
||||
Object.assign(result, querystring.parse(item));
|
||||
const params = new URLSearchParams(item);
|
||||
params.forEach((value, key) => {
|
||||
// $FlowExpectedError[prop-missing]
|
||||
result[key] = value;
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user