From 7ebef567ce30d848dd8f9374fd70699fd91acb29 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 25 Jul 2016 00:31:35 +0200 Subject: systematic revision of =~ usage in AV Where appropriate, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with? --- actionview/lib/action_view/helpers/url_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionview/lib/action_view/helpers/url_helper.rb') diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index fb6426b997..5d7940a7b1 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -2,6 +2,7 @@ require 'action_view/helpers/javascript_helper' require 'active_support/core_ext/array/access' require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/string/output_safety' +require 'active_support/core_ext/regexp' module ActionView # = Action View URL Helpers @@ -550,7 +551,7 @@ module ActionView url_string.chomp!("/") if url_string.start_with?("/") && url_string != "/" - if url_string =~ /^\w+:\/\// + if %r{^\w+://}.match?(url_string) url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}" else url_string == request_uri -- cgit v1.2.3