Skip to content
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

Replace percent escapes in file URL before using as path #876

Closed

Conversation

hermanschaaf
Copy link
Contributor

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

  1. Create a project with a space in the name:
    screen shot 2015-04-16 at 17 23 46
  2. Follow the steps in OPTION 2 for running from a bundled file, i.e. create the main.bundle file, add it to the project if is not there already, and uncomment jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  3. Run the application. This is what happens:

screen shot 2015-04-16 at 17 27 48

To prove that it has to do with a space in the name, refactor the project name to not contain a space:

screen shot 2015-04-16 at 17 28 27

Run the project again, and now it runs successfully:

screen shot 2015-04-16 at 17 30 18

The fix

The scriptURL variable passed to the onComplete method contains url-encoded spaces (%20), which we need to convert back to spaces before using the URL as a path. This is achieved with stringByReplacingPercentEscapesUsingEncoding, 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.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 16, 2015
@sahrens sahrens closed this in 4242bd9 Apr 24, 2015
ayushjainrksh pushed a commit to MLH-Fellowship/react-native that referenced this pull request Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants