File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 11require 'eventmachine'
22require 'em-websocket'
33require 'http/parser'
4+ require 'uri'
45
56module Guard
67 class LiveReload
@@ -9,12 +10,13 @@ class WebSocket < EventMachine::WebSocket::Connection
910 def dispatch ( data )
1011 parser = Http ::Parser . new
1112 parser << data
13+ request_path = URI . parse ( parser . request_url ) . path
1214 if parser . http_method != 'GET' || parser . upgrade?
1315 super #pass the request to websocket
14- elsif parser . request_path == '/livereload.js'
16+ elsif request_path == '/livereload.js'
1517 _serve_file ( _livereload_js_file )
16- elsif File . exist? ( parser . request_path [ 1 ..-1 ] )
17- _serve_file ( parser . request_path [ 1 ..-1 ] ) # Strip leading slash
18+ elsif File . exist? ( request_path [ 1 ..-1 ] )
19+ _serve_file ( request_path [ 1 ..-1 ] ) # Strip leading slash
1820 else
1921 send_data ( "HTTP/1.1 404 Not Found\r \n Content-Type: text/plain\r \n Content-Length: 13\r \n \r \n 404 Not Found" )
2022 close_connection_after_writing
You can’t perform that action at this time.
0 commit comments