Replace percent escapes in file URL before using as path #876
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is to fix a bug that prevents bundling of projects that contain spaces (or other special characters) in their names.
Reproduction steps before the fix
OPTION 2
for running from a bundled file, i.e. create themain.bundle
file, add it to the project if is not there already, and uncommentjsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
To prove that it has to do with a space in the name, refactor the project name to not contain a space:
Run the project again, and now it runs successfully:
The fix
The
scriptURL
variable passed to theonComplete
method contains url-encoded spaces (%20
), which we need to convert back to spaces before using the URL as a path. This is achieved withstringByReplacingPercentEscapesUsingEncoding
, which allows us to fix the bug without break any existining APIs.Note: This is my first pull request to a Facebook open source project, and I just completed the CLA.