mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Align parsing of custom resolver options, rename arg (#42392)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42392 Follow-up to https://github.com/facebook/react-native/pull/42333 following internal feedback. We are now aligning this to match the [`metro build` command](https://github.com/facebook/metro/blob/702e1b8fc7ab8b973bcd53f1a41f7e797cbf7dca/packages/metro/src/commands/build.js#L85-L91). This also improves validation on parsing (done after initial `commander` arg parsing as variadic string). Changelog: [Internal] (same as https://github.com/facebook/react-native/pull/42333) Reviewed By: motiz88 Differential Revision: D52911017 fbshipit-source-id: 54049aa20c9db344a0f485fddf62fb267e672376
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4681e407b2
commit
4e92f87dfd
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
import querystring from 'querystring';
|
||||
|
||||
export default function parseKeyValueParamArray(
|
||||
keyValueArray: $ReadOnlyArray<string>,
|
||||
): Record<string, string> {
|
||||
const result = {};
|
||||
|
||||
for (const item of keyValueArray) {
|
||||
if (item.indexOf('=') === -1) {
|
||||
throw new Error('Expected parameter to include "=" but found: ' + item);
|
||||
}
|
||||
if (item.indexOf('&') !== -1) {
|
||||
throw new Error('Parameter cannot include "&" but found: ' + item);
|
||||
}
|
||||
Object.assign(result, querystring.parse(item));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user