Merge pull request #4228 from jekyll/pull/fix-file-edge-servlet
Fix an edge where file is sometimes not returned properly.
This commit is contained in:
		
						commit
						68d58f4183
					
				|  | @ -18,24 +18,26 @@ module Jekyll | ||||||
|           return super |           return super | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         # --------------------------------------------------------------------- |  | ||||||
|         # file > file/index.html > file.html > directory -> Having a directory |         # file > file/index.html > file.html > directory -> Having a directory | ||||||
|         # with the same name as a file will result in the file being served the |         # with the same name as a file will result in the file being served the way | ||||||
|         # way that Nginx behaves (probably not exactly...) For browsing. |         # that Nginx behaves (probably not exactly...) For browsing. | ||||||
|         # --------------------------------------------------------------------- |  | ||||||
| 
 | 
 | ||||||
|         def search_file(req, res, basename) |         def search_file(req, res, basename) | ||||||
|           return file if (file = super) || (file = super req, res, "#{basename}.html") |           file = super || super(req, res, "#{basename}.html") | ||||||
| 
 | 
 | ||||||
|  |           return file if file | ||||||
|           file = "#{req.path.gsub(/\/\Z/, "")}.html" |           file = "#{req.path.gsub(/\/\Z/, "")}.html" | ||||||
|           if file && File.file?(File.join(@config[:DocumentRoot], file)) |           if file && File.file?(File.join(@config[:DocumentRoot], file)) | ||||||
|             return ".html" |             return ".html" | ||||||
|           end |           end | ||||||
|  | 
 | ||||||
|           nil |           nil | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         def extract_headers(opts) |         def extract_headers(opts) | ||||||
|           @headers = add_defaults(opts.fetch("webrick", {}).fetch("headers", {})) |           @headers = add_defaults(opts.fetch("webrick", {}).fetch("headers", { | ||||||
|  |             # Nothing. | ||||||
|  |           })) | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         def add_defaults(opts) |         def add_defaults(opts) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue