diff --git a/lib/react/server_rendering/webpacker_manifest_container.rb b/lib/react/server_rendering/webpacker_manifest_container.rb index 4f2ecfbc..421bf118 100644 --- a/lib/react/server_rendering/webpacker_manifest_container.rb +++ b/lib/react/server_rendering/webpacker_manifest_container.rb @@ -27,7 +27,7 @@ def find_asset(logical_path) asset_path = manifest.lookup(logical_path).to_s if asset_path.start_with?('http') # Get a file from the webpack-dev-server - dev_server_asset = open(asset_path).read + dev_server_asset = URI.open(asset_path).read # Remove `webpack-dev-server/client/index.js` code which causes ExecJS to 💥 dev_server_asset.sub!(CLIENT_REQUIRE, '//\0') dev_server_asset @@ -44,7 +44,7 @@ def find_asset(logical_path) ds = Webpacker.dev_server # Remove the protocol and host from the asset path. Sometimes webpacker includes this, sometimes it does not asset_path.slice!("#{ds.protocol}://#{ds.host_with_port}") - dev_server_asset = open("#{ds.protocol}://#{ds.host_with_port}#{asset_path}").read + dev_server_asset = URI.open("#{ds.protocol}://#{ds.host_with_port}#{asset_path}").read dev_server_asset.sub!(CLIENT_REQUIRE, '//\0') dev_server_asset else diff --git a/test/support/webpacker_helpers.rb b/test/support/webpacker_helpers.rb index d1d26cf9..eb2f6e8f 100644 --- a/test/support/webpacker_helpers.rb +++ b/test/support/webpacker_helpers.rb @@ -101,7 +101,7 @@ def dev_server_running? return false unless example_asset_path return false unless example_asset_path.start_with?('http://localhost:8080') begin - file = open('http://localhost:8080/packs/application.js') + file = URI.open('http://localhost:8080/packs/application.js') rescue StandardError => e file = nil end @@ -134,7 +134,7 @@ def dev_server_running? example_asset_path = manifest_data.values.first return false unless example_asset_path begin - file = open("#{ds.protocol}://#{ds.host}:#{ds.port}#{example_asset_path}") + file = URI.open("#{ds.protocol}://#{ds.host}:#{ds.port}#{example_asset_path}") rescue StandardError => e file = nil end