-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent crash in findMatchingSimulator #59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for submitting this PR! I left a comment to help us get through the review process :)
@@ -31,7 +31,7 @@ function findMatchingSimulator(simulators, simulatorString) { | |||
const parsedSimulatorName = simulatorString | |||
? simulatorString.match(/(.*)? (?:\((.*)?\))?/) | |||
: []; | |||
if (parsedSimulatorName[2] !== undefined) { | |||
if (parsedSimulatorName && parsedSimulatorName[2] !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting.
On line 31, we make sure it's either a matched value or an array - it shouldn't be "undefined" at all.
Could you provide more details when this would be null, or causing a crash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.match()
may return null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it confused me:
simulatorString
? simulatorString.match(/(.*)? (?:\((.*)?\))?/)
: [];
Thought we check on simulator.match
instead xd
@@ -31,7 +31,7 @@ function findMatchingSimulator(simulators, simulatorString) { | |||
const parsedSimulatorName = simulatorString | |||
? simulatorString.match(/(.*)? (?:\((.*)?\))?/) | |||
: []; | |||
if (parsedSimulatorName[2] !== undefined) { | |||
if (parsedSimulatorName && parsedSimulatorName[2] !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.match()
may return null
findMatchingSimulator
could crash if the simulator's name is custom (renamed in Xcode) for ex:iPhone6v11
.After this fix it doesn't crash and the correct custom named simulator is chosen.