Corrected with rubocop cop 'Style/RegexpLiteral'.
This commit is contained in:
parent
7929477838
commit
834ad2d64a
5 changed files with 13 additions and 13 deletions
|
@ -76,7 +76,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
# validate url
|
||||
messages = {}
|
||||
if !Setting.get('system_online_service')
|
||||
if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/
|
||||
if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
|
||||
messages[:url] = 'A URL looks like http://zammad.example.com'
|
||||
end
|
||||
end
|
||||
|
@ -107,7 +107,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
# split url in http_type and fqdn
|
||||
settings = {}
|
||||
if !Setting.get('system_online_service')
|
||||
if params[:url] =~ /^(http|https):\/\/(.+?)$/
|
||||
if params[:url] =~ %r{/^(http|https)://(.+?)$}
|
||||
Setting.set('http_type', $1)
|
||||
settings[:http_type] = $1
|
||||
Setting.set('fqdn', $2)
|
||||
|
|
|
@ -6,7 +6,7 @@ class ImportOtrsController < ApplicationController
|
|||
return if setup_done_response
|
||||
|
||||
# validate
|
||||
if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/
|
||||
if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
|
||||
render json: {
|
||||
result: 'invalid',
|
||||
message: 'Invalid!',
|
||||
|
@ -44,7 +44,7 @@ class ImportOtrsController < ApplicationController
|
|||
suffixes.each {|suffix|
|
||||
url = params[:url] + suffix + '?Action=ZammadMigrator'
|
||||
# strip multible / in url
|
||||
url.gsub!(/([^:])(\/+\/)/, '\\1/')
|
||||
url.gsub!(%r{([^:])(/+/)}, '\\1/')
|
||||
response = UserAgent.request( url )
|
||||
|
||||
#Setting.set('import_mode', true)
|
||||
|
|
|
@ -110,7 +110,7 @@ add a avatar
|
|||
|
||||
# twitter workaround to get bigger avatar images
|
||||
# see also https://dev.twitter.com/overview/general/user-profile-images-and-banners
|
||||
if data[:url] =~ /\/\/pbs.twimg.com\//i
|
||||
if data[:url] =~ %r{//pbs.twimg.com/}i
|
||||
data[:url].sub!(/normal\.png$/, 'bigger.png')
|
||||
end
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class Package < ApplicationModel
|
|||
def self._package_base_dir?(package_base_dir)
|
||||
package = false
|
||||
Dir.glob( package_base_dir + '/*.szpm') do |entry|
|
||||
package = entry.sub( /^.*\/(.+?)\.szpm$/, '\1')
|
||||
package = entry.sub( %r{^.*/(.+?)\.szpm$}, '\1')
|
||||
end
|
||||
if package == false
|
||||
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
|
||||
|
@ -133,7 +133,7 @@ class Package < ApplicationModel
|
|||
entry = entry.sub( '//', '/' )
|
||||
file = entry
|
||||
file = file.sub( /#{package_base_dir.to_s}/, '' )
|
||||
file = file.sub( /^\//, '' )
|
||||
file = file.sub( %r{^/}, '' )
|
||||
|
||||
# ignore files
|
||||
if file =~ /^README/
|
||||
|
|
|
@ -83,10 +83,10 @@ class String
|
|||
string.gsub!( /^\s*/m, '' )
|
||||
|
||||
# pre/code handling 1/2
|
||||
string.gsub!( /<pre>(.+?)<\/pre>/m ) { |placeholder|
|
||||
string.gsub!( %r{<pre>(.+?)</pre>}m ) { |placeholder|
|
||||
placeholder = placeholder.gsub(/\n/, '###BR###')
|
||||
}
|
||||
string.gsub!( /<code>(.+?)<\/code>/m ) { |placeholder|
|
||||
string.gsub!( %r{<code>(.+?)</code>/}m ) { |placeholder|
|
||||
placeholder = placeholder.gsub(/\n/, '###BR###')
|
||||
}
|
||||
|
||||
|
@ -103,12 +103,12 @@ class String
|
|||
string.gsub!(/<blockquote(| [^>]*)>/i, '> ')
|
||||
|
||||
# add hr
|
||||
string.gsub!(/<hr(|\/| [^>]*)>/i, "___\n")
|
||||
string.gsub!(%r{<hr(|/| [^>]*)>}i, "___\n")
|
||||
|
||||
# add new lines
|
||||
string.gsub!( /\<(br|table)(|\/| [^>]*)\>/i, "\n" )
|
||||
string.gsub!( /\<\/(div|p|pre|blockquote|table|tr)(|\s.+?)\>/i, "\n" )
|
||||
string.gsub!( /\<\/td\>/i, ' ' )
|
||||
string.gsub!( %r{\<(br|table)(|/| [^>]*)\>}i, "\n" )
|
||||
string.gsub!( %r{\</(div|p|pre|blockquote|table|tr)(|\s.+?)\>}i, "\n" )
|
||||
string.gsub!( %r{/</td\>}i, ' ' )
|
||||
|
||||
# strip all other tags
|
||||
string.gsub!( /\<.+?\>/, '' )
|
||||
|
|
Loading…
Reference in a new issue