From 4e31f86cf089db6fa100e131d45ea52df1973389 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 2 Dec 2015 11:51:04 +0200 Subject: [PATCH] Story#109340154 - domain always uses unicode to make search --- Gemfile | 1 + Gemfile.lock | 5 +++++ app/controllers/whois_records_controller.rb | 8 +++++--- app/views/layouts/application.haml | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index e7957b21..e5c1c1ec 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source 'https://rubygems.org' # core gem 'rails', '4.2.1' +gem 'simpleidn', '0.0.5' # For punycode # model related gem 'pg', '~> 0.18.0' diff --git a/Gemfile.lock b/Gemfile.lock index e13340bb..f2d63fa3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -134,6 +134,7 @@ GEM ruby_parser (3.6.5) sexp_processor (~> 4.1) sexp_processor (4.5.0) + simpleidn (0.0.5) slop (3.6.0) spring (1.3.4) sprockets (3.0.1) @@ -167,5 +168,9 @@ DEPENDENCIES rails (= 4.2.1) recaptcha (~> 0.4.0) rubocop (~> 0.26.1) + simpleidn (= 0.0.5) spring (~> 1.3.3) unicorn + +BUNDLED WITH + 1.10.6 diff --git a/app/controllers/whois_records_controller.rb b/app/controllers/whois_records_controller.rb index 33257956..191d5ab7 100644 --- a/app/controllers/whois_records_controller.rb +++ b/app/controllers/whois_records_controller.rb @@ -2,8 +2,10 @@ class WhoisRecordsController < ApplicationController def show # fix id if there is no correct format params[:id] = "#{params[:id]}.#{params[:format]}" if !['json', 'html'].include? params[:format] + @domain_name = SimpleIDN.to_unicode(params[:id].to_s) + @verified = verify_recaptcha - @whois_record = WhoisRecord.find_by(name: params[:id]) + @whois_record = WhoisRecord.find_by(name: @domain_name) begin respond_to do |format| @@ -13,7 +15,7 @@ def show return render json: json else return render json: { - name: params[:id], + name: @domain_name, error: "Domain not found."}, status: :not_found end @@ -22,7 +24,7 @@ def show rescue ActionController::UnknownFormat if @whois_record.present? else - return render text: "Domain not found: #{CGI::escapeHTML params[:id]}", status: :not_found + return render text: "Domain not found: #{CGI::escapeHTML @domain_name}", status: :not_found end end end diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 66f6d719..2fc4e9f1 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -8,7 +8,7 @@ %meta{:content => "Full stack top-level domain (TLD) management.", :name => "description"}/ %meta{:content => "Gitlab LTD", :name => "author"}/ %title - Whois record: #{params[:id]} + Whois record: #{@domain_name} %body = render 'shared/flash' = yield