mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 02:24:23 +00:00
Cast name to String to ensure .match is available
Summary: PR for issue #12444 In `validateProjectName` in `react-native-cli` `name.match` is called but it's not certain that `name`is a String. This casts `name`to a String before doing the match. I didn't find any tests for this file so I didn't add any. Reproduce: ``` cd react-native-cli npm install node index.js init 123 ``` Before this PR the code throws an exception, after this PR the intended `console.error` is printed. Closes https://github.com/facebook/react-native/pull/12447 Differential Revision: D4584041 fbshipit-source-id: 117e76570aa9975ac851192b030c5a77daf19bcc
This commit is contained in:
parent
cb68b97289
commit
c7f2c53fbf
2
react-native-cli/index.js
vendored
2
react-native-cli/index.js
vendored
@ -167,7 +167,7 @@ if (cli) {
|
||||
}
|
||||
|
||||
function validateProjectName(name) {
|
||||
if (!name.match(/^[$A-Z_][0-9A-Z_$]*$/i)) {
|
||||
if (!String(name).match(/^[$A-Z_][0-9A-Z_$]*$/i)) {
|
||||
console.error(
|
||||
'"%s" is not a valid name for a project. Please use a valid identifier ' +
|
||||
'name (alphanumeric).',
|
||||
|
Loading…
x
Reference in New Issue
Block a user