From 475a0c20f6ded05ea66b71d8521674e3de5a7c2d Mon Sep 17 00:00:00 2001 From: Alexander Paterson Date: Mon, 14 Nov 2016 11:38:09 -0800 Subject: [PATCH] Decode URI in asset server Summary: Solving this issue https://github.com/facebook/react-native/issues/10364 In development when assets are requested from AssetServer, it tries to find them with URI-friendly filenames. I added a single line to decode these filenames. Tests are passing. Couldn't find any discussion regarding whether this is a good idea. This was causing some members of my team a bit of grief earlier. Closes https://github.com/facebook/react-native/pull/10365 Differential Revision: D4168401 Pulled By: hramos fbshipit-source-id: 9ed3606392d8a6f170998caaf0f9254ba4879b49 --- .../node-haste/lib/__tests__/getAssetDataFromName-test.js | 8 ++++++++ react-packager/src/node-haste/lib/getAssetDataFromName.js | 1 + 2 files changed, 9 insertions(+) diff --git a/react-packager/src/node-haste/lib/__tests__/getAssetDataFromName-test.js b/react-packager/src/node-haste/lib/__tests__/getAssetDataFromName-test.js index ff61c405..a1e6b8cc 100644 --- a/react-packager/src/node-haste/lib/__tests__/getAssetDataFromName-test.js +++ b/react-packager/src/node-haste/lib/__tests__/getAssetDataFromName-test.js @@ -62,6 +62,14 @@ describe('getAssetDataFromName', () => { name: 'c', platform: 'ios', }); + + expect(getAssetDataFromName('a/b /c.png')).toEqual({ + resolution: 1, + assetName: 'a/b /c.png', + type: 'png', + name: 'c', + platform: null, + }); }); describe('resolution extraction', () => { diff --git a/react-packager/src/node-haste/lib/getAssetDataFromName.js b/react-packager/src/node-haste/lib/getAssetDataFromName.js index d0c04afc..04051175 100644 --- a/react-packager/src/node-haste/lib/getAssetDataFromName.js +++ b/react-packager/src/node-haste/lib/getAssetDataFromName.js @@ -42,6 +42,7 @@ function getAssetDataFromName(filename, platforms) { } else { assetName = filename; } + assetName = decodeURIComponent(assetName); return { resolution: resolution,