File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,10 @@ def initialize
28
28
url = URI ( app_uri_path . read . chomp )
29
29
30
30
@ssl = T . let ( url . scheme == "https" , T ::Boolean )
31
- @uri = T . let ( T . must ( url . path ) , T . nilable ( String ) )
31
+ @address = T . let (
32
+ [ url . host , url . path ] . reject { |component | component . nil? || component . empty? } . join ( "/" ) ,
33
+ T . nilable ( String ) ,
34
+ )
32
35
@port = T . let ( T . must ( url . port ) . to_i , Integer )
33
36
end
34
37
end
@@ -62,9 +65,9 @@ def check_if_server_is_running!
62
65
63
66
sig { params ( path : String , timeout : T . nilable ( Float ) ) . returns ( Net ::HTTPResponse ) }
64
67
def request ( path , timeout = nil )
65
- raise ServerAddressUnknown unless @uri
68
+ raise ServerAddressUnknown unless @address
66
69
67
- http = Net ::HTTP . new ( @uri , @port )
70
+ http = Net ::HTTP . new ( @address , @port )
68
71
http . use_ssl = @ssl
69
72
http . read_timeout = timeout if timeout
70
73
http . get ( "/ruby_lsp_rails/#{ path } " )
Original file line number Diff line number Diff line change @@ -62,6 +62,15 @@ class RailsClientTest < ActiveSupport::TestCase
62
62
RailsClient . new . check_if_server_is_running!
63
63
end
64
64
end
65
+
66
+ test "defaults path to localhost" do
67
+ File . write ( "#{ Dir . pwd } /test/dummy/tmp/app_uri.txt" , "http://localhost:3000" )
68
+
69
+ client = RailsClient . new
70
+ assert_equal ( "localhost" , client . instance_variable_get ( :@address ) )
71
+ assert_equal ( 3000 , client . instance_variable_get ( :@port ) )
72
+ refute ( client . instance_variable_get ( :@ssl ) )
73
+ end
65
74
end
66
75
end
67
76
end
You can’t perform that action at this time.
0 commit comments