Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resources to ilinks check, see #911 #912

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/nanoc/extra/checking/checks/internal_links.rb
Expand Up @@ -15,7 +15,10 @@ def run
# TODO: de-duplicate this (duplicated in external links check)
filenames = output_filenames.select { |f| File.extname(f) == '.html' }
hrefs_with_filenames = ::Nanoc::Extra::LinkCollector.new(filenames, :internal).filenames_per_href
hrefs_with_filenames.each_pair do |href, fns|
resource_uris_with_filenames = ::Nanoc::Extra::LinkCollector.new(filenames, :internal).filenames_per_resource_uri

uris = hrefs_with_filenames.merge(resource_uris_with_filenames)
uris.each_pair do |href, fns|
fns.each do |filename|
next if valid?(href, filename)

Expand Down
15 changes: 15 additions & 0 deletions test/extra/checking/checks/test_internal_links.rb
Expand Up @@ -16,6 +16,21 @@ def test_run
end
end

def test_resource_uris
with_site do |site|
# Create files
FileUtils.mkdir_p('output')
File.open('output/bar.html', 'w') { |io| io.write('<link rel="stylesheet" href="/styledinges.css">') }

# Create check
check = Nanoc::Extra::Checking::Checks::InternalLinks.create(site)
check.run

# Test
assert check.issues.size == 1
end
end

def test_valid?
with_site do |site|
# Create files
Expand Down