Skip to content

Commit 72f6093

Browse files
committed
Use URI.open instead of open
Using open via the following snippet: require 'open-uri' open('https//...') In ruby 2 results in the following deprecation warning: warning: calling URI.open via Kernel#open is deprecated call URI.open directly or use URI#open In ruby 3 results in the following exception: Errno::ENOENT (No such file or directory @ rb_sysopen - https://...) The fixes by calling open through URI.
1 parent f8148d5 commit 72f6093

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/react/server_rendering/webpacker_manifest_container.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def find_asset(logical_path)
2727
asset_path = manifest.lookup(logical_path).to_s
2828
if asset_path.start_with?('http')
2929
# Get a file from the webpack-dev-server
30-
dev_server_asset = open(asset_path).read
30+
dev_server_asset = URI.open(asset_path).read
3131
# Remove `webpack-dev-server/client/index.js` code which causes ExecJS to 💥
3232
dev_server_asset.sub!(CLIENT_REQUIRE, '//\0')
3333
dev_server_asset
@@ -44,7 +44,7 @@ def find_asset(logical_path)
4444
ds = Webpacker.dev_server
4545
# Remove the protocol and host from the asset path. Sometimes webpacker includes this, sometimes it does not
4646
asset_path.slice!("#{ds.protocol}://#{ds.host_with_port}")
47-
dev_server_asset = open("#{ds.protocol}://#{ds.host_with_port}#{asset_path}").read
47+
dev_server_asset = URI.open("#{ds.protocol}://#{ds.host_with_port}#{asset_path}").read
4848
dev_server_asset.sub!(CLIENT_REQUIRE, '//\0')
4949
dev_server_asset
5050
else

test/support/webpacker_helpers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def dev_server_running?
101101
return false unless example_asset_path
102102
return false unless example_asset_path.start_with?('http://localhost:8080')
103103
begin
104-
file = open('http://localhost:8080/packs/application.js')
104+
file = URI.open('http://localhost:8080/packs/application.js')
105105
rescue StandardError => e
106106
file = nil
107107
end
@@ -134,7 +134,7 @@ def dev_server_running?
134134
example_asset_path = manifest_data.values.first
135135
return false unless example_asset_path
136136
begin
137-
file = open("#{ds.protocol}://#{ds.host}:#{ds.port}#{example_asset_path}")
137+
file = URI.open("#{ds.protocol}://#{ds.host}:#{ds.port}#{example_asset_path}")
138138
rescue StandardError => e
139139
file = nil
140140
end

0 commit comments

Comments
 (0)