Skip to content

Commit 3d01dad

Browse files
committed
Merge pull request #109 from isotes/serve-html
Mime type for HTML files and support index.html
2 parents e614064 + 4fedb31 commit 3d01dad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/guard/livereload/websocket.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def dispatch(data)
1212
parser << data
1313
# prepend with '.' to make request url usable as a file path
1414
request_path = '.' + URI.parse(parser.request_url).path
15+
request_path += '/index.html' if File.directory? request_path
1516
if parser.http_method != 'GET' || parser.upgrade?
1617
super #pass the request to websocket
1718
elsif request_path == './livereload.js'
@@ -33,7 +34,8 @@ def _serve_file(path)
3334
end
3435

3536
def _content_type(path)
36-
case File.extname(path)
37+
case File.extname(path).downcase
38+
when '.html', '.htm' then 'text/html'
3739
when '.css' then 'text/css'
3840
when '.js' then 'application/ecmascript'
3941
when '.gif' then 'image/gif'

0 commit comments

Comments
 (0)