app/controllers/lookup_controller.rb in local_pac-0.1.13 vs app/controllers/lookup_controller.rb in local_pac-0.2.0
- old
+ new
@@ -5,27 +5,27 @@
get '/' do
redirect to('/proxy.pac')
end
get '/:name' do
+ file = local_storage.find(params[:name].to_s)
+ fail Sinatra::NotFound, params[:name].to_s if file.nil?
+
haml :lookup, layout: :application
end
post '/:name' do
@file = local_storage.find(params[:name].to_s)
@uri = Addressable::URI.heuristic_parse(params[:url].to_s)
- if @file.nil?
- fail Sinatra::NotFound, params[:name]
- else
- parser = LocalPac::ProxyPac::PacParser.new(file: @file)
+ fail Sinatra::NotFound, params[:name].to_s if @file.nil?
- begin
- @result = parser.find(@uri)
- rescue Exceptions::PacFileInvalid
- fail I18n.t('errors.invalid_proxy_pac', name: params[:name] )
- end
+ parser = LocalPac::ProxyPac::PacParser.new(file: @file)
+ begin
+ @result = parser.find(@uri)
+ rescue Exceptions::PacFileInvalid
+ fail I18n.t('errors.invalid_proxy_pac', name: params[:name] )
end
haml :lookup_result, layout: :application
end
end