Skip to content

Commit 54879bd

Browse files
author
Yuri Smirnov
committed
fix warning
1 parent 519e2ac commit 54879bd

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/simplecov-html.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ def assets_path(name)
9595
File.join("./assets", SimpleCov::Formatter::HTMLFormatter::VERSION, name)
9696
end
9797

98+
def to_id(value)
99+
value.gsub(/^[^a-zA-Z]+/, "").gsub(/[^a-zA-Z0-9\-_]/, "")
100+
end
101+
98102
def asset_inline(name)
99103
path = File.join(@public_assets_dir, name)
100104

@@ -119,7 +123,6 @@ def formatted_source_file(source_file)
119123

120124
# Returns a table containing the given source files
121125
def formatted_file_list(title, source_files)
122-
title_id = title.gsub(/^[^a-zA-Z]+/, "").gsub(/[^a-zA-Z0-9\-_]/, "")
123126
template("file_list").result(binding)
124127
end
125128

views/file_list.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="file_list_container" id="<%= title_id %>">
1+
<div class="file_list_container" id="<%= to_id(title) %>">
22
<h2>
33
<span class="group_name"><%= title %></span>
44
(<span class="covered_percent">
@@ -13,7 +13,7 @@
1313
)
1414
</h2>
1515

16-
<a name="<%= title_id %>"></a>
16+
<a name="<%= to_id(title) %>"></a>
1717

1818
<div>
1919
<b><%= source_files.length %></b> files in total.

0 commit comments

Comments
 (0)