Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Move the DoubleSlashChecker to a separate file as a part of custom mo…
Browse files Browse the repository at this point in the history
…dule
  • Loading branch information
dshevtsov committed Jan 15, 2019
1 parent ac2ed20 commit f1fcefd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require 'colorator'
# Load ruby files with helper methods from the 'rakelib/' directory
require_relative 'rakelib/link-checker.rb'
require_relative 'rakelib/converter.rb'
require_relative 'rakelib/double-slash-check.rb'

desc "Same as 'rake', 'rake preview'"
task default: %w[preview]
Expand Down
20 changes: 20 additions & 0 deletions rakelib/double-slash-check.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Custom check for html-proofer to find double forward slashes in URLs.
module LinkChecker
class DoubleSlashCheck < ::HTMLProofer::Check
def slash?
return false if @link.href.nil?
@link.href.match %r{\w//}
end

def run
@html.css('a').each do |node|
@link = create_element(node)
line = node.line

if slash?
return add_issue("Remove double forward slashes from URLs", line: line)
end
end
end
end
end
21 changes: 0 additions & 21 deletions rakelib/link-checker.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
# frozen_string_literal: true

# Custom class to find double forward slashes in URLs.

class DoubleSlashCheck < ::HTMLProofer::Check

def slash?
return false if @link.href.nil?
@link.href.match /\w\/\//
end

def run
@html.css('a').each do |node|
@link = create_element(node)
line = node.line

if slash?
return add_issue("Remove double forward slashes from URLs", line: line)
end
end
end
end

# Helper methods to configure and run html-proofer
module LinkChecker
# Run html-proofer to check the generated HTML pages
Expand Down

0 comments on commit f1fcefd

Please sign in to comment.