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

Fix Warning/Error Caused by Using 'open' Instead of 'URI.open' #1099

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/react/server_rendering/webpacker_manifest_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/support/webpacker_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down