Skip to content

Commit 2041645

Browse files
committed
Refactor #73: Use delete_prefix() for better code reading
1 parent 7461c20 commit 2041645

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

_tests/custom_checks.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@ class CustomChecks < ::HTMLProofer::Check
88
BASE_PATH = '_site'
99

1010
def run
11-
current_filename = @runner.current_filename
12-
puts "\tchecking ... " + current_filename[5..].split('.').first
13-
14-
check_directory_structure
11+
filename = @runner.current_filename
12+
puts "\tchecking ... " + filename.delete_prefix('_site')
13+
check_directory_structure(filename) if filename.end_with?('.html')
1514
end
1615

1716
# Check directory structure to ensure all pages are generated as index.html
1817
# This ensures proper routing for both /foobar/ and /foobar pathes.
19-
def check_directory_structure
18+
def check_directory_structure(filename)
2019
allowed_names = ['index.html', '404.html']
2120
current_file = @runner.current_filename
2221

23-
# Only check HTML files
24-
return unless current_file.end_with?('.html')
25-
2622
# Get the filename
2723
filename = File.basename(current_file)
2824

0 commit comments

Comments
 (0)