Fix a bug that error is raised when multi-line format

This commit is contained in:
yoshihara 2015-04-20 15:50:32 +09:00
parent 79f0b1fe28
commit 098b74de4b

View File

@ -21,11 +21,14 @@ class ApiController < ApplicationController
def regexp_preview
preview = RegexpPreview.processor(params[:format]).new(params[:file], params[:format], params)
matches = preview.matches
render json: {
params: {
setting: {
regexp: preview.regexp.try(:source),
time_format: preview.time_format,
# NOTE: regexp and timeformat are used when format == 'apache' || 'nginx' || etc.
# TODO: prepare rendered JSON by prcessor(RegexpPreview::{Signle,Multi}Line
regexp: preview.try(:regexp).try(:source),
time_format: preview.try(:time_format),
}
},
matches: matches.compact,