List only YAML files

master
Guillaume Dott 2014-12-09 12:50:52 +01:00
parent 156b052b63
commit d1fc8c7f58
1 changed files with 2 additions and 1 deletions

View File

@ -27,7 +27,8 @@ get "/data/:game.json" do |game|
data_file = Pathname.new(File.join(settings.data_folder, game)) data_file = Pathname.new(File.join(settings.data_folder, game))
halt(404) unless data_file.directory? halt(404) unless data_file.directory?
json data_file.children(false).map { |path| path.to_s.sub(/.yml$/, '') } json data_file.children(false).select { |path| path.to_s.end_with?('.yml') }
.map { |path| path.to_s.sub(/.yml$/, '') }
end end
get "/data/:game/:file.json" do |game, file| get "/data/:game/:file.json" do |game, file|