summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2022-08-24 13:45:20 +0000
committerGo MAEDA <maeda@farend.jp>2022-08-24 13:45:20 +0000
commit80b7a83940752f3647dd2974a112056e37438cef (patch)
tree8095ab5c208a2a479c9f3eb5b56277673c0b3ac2 /lib
parentf8033a069f99fd9947f05c2f4076bd8f0f575f98 (diff)
downloadredmine-80b7a83940752f3647dd2974a112056e37438cef.tar.gz
redmine-80b7a83940752f3647dd2974a112056e37438cef.zip
Use start_with? or end_with? to check the first or last character of a string (#37591).
Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@21774 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/diff_table.rb6
-rw-r--r--lib/redmine/export/pdf.rb2
-rw-r--r--lib/redmine/scm/adapters/abstract_adapter.rb6
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/redmine/diff_table.rb b/lib/redmine/diff_table.rb
index 2976d2228..ca8c4b9d2 100644
--- a/lib/redmine/diff_table.rb
+++ b/lib/redmine/diff_table.rb
@@ -118,7 +118,7 @@ module Redmine
end
def parse_line(line, type="inline")
- if line[0, 1] == "+"
+ if line.start_with?('+')
diff = diff_for_added_line
diff.line_right = line[1..-1]
diff.nb_line_right = @line_num_r
@@ -126,7 +126,7 @@ module Redmine
@line_num_r += 1
@added += 1
true
- elsif line[0, 1] == "-"
+ elsif line.start_with?('-')
diff = Diff.new
diff.line_left = line[1..-1]
diff.nb_line_left = @line_num_l
@@ -137,7 +137,7 @@ module Redmine
true
else
write_offsets
- if /\s/.match?(line[0, 1])
+ if line.start_with?(/\s/)
diff = Diff.new
diff.line_right = line[1..-1]
diff.nb_line_right = @line_num_r
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb
index e586a2a0a..cdf8eca3c 100644
--- a/lib/redmine/export/pdf.rb
+++ b/lib/redmine/export/pdf.rb
@@ -120,7 +120,7 @@ module Redmine
end
def get_sever_url(url)
- if !empty_string(url) and (url[0, 1] == '/')
+ if !empty_string(url) and url.start_with?('/')
Setting.host_name.split('/')[0] + url
else
url
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb
index 5d92bb2d7..0ad3d7f45 100644
--- a/lib/redmine/scm/adapters/abstract_adapter.rb
+++ b/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -158,12 +158,12 @@ module Redmine
def with_leading_slash(path)
path ||= ''
- (path[0, 1]!="/") ? "/#{path}" : path
+ path.start_with?('/') ? path : "/#{path}"
end
def with_trailling_slash(path)
path ||= ''
- (path[-1, 1] == "/") ? path : "#{path}/"
+ path.end_with?('/') ? path : "#{path}/"
end
def without_leading_slash(path)
@@ -173,7 +173,7 @@ module Redmine
def without_trailling_slash(path)
path ||= ''
- (path[-1, 1] == "/") ? path[0..-2] : path
+ path.end_with?('/') ? path[0..-2] : path
end
def valid_name?(name)