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

Hash not exist in path with implicit index #714

Closed
phenylshima opened this issue Jun 8, 2022 · 2 comments · Fixed by #715
Closed

Hash not exist in path with implicit index #714

phenylshima opened this issue Jun 8, 2022 · 2 comments · Fixed by #715

Comments

@phenylshima
Copy link

phenylshima commented Jun 8, 2022

Summary

When the hash foo/bar/index.html#hash exists, linking to foo/bar#hash(without index.html and trailing slash) results in

internally linking to foo/bar#hash; the file exists, but the hash 'hash' does not

Steps to reproduce

  1. Create directories and files as follows.
./test
┣ foo/
┃  ┗ bar/
┃     ┗ index.html
┗ index.html
  1. Write the following to ./test/index.html
<!DOCTYPE html>
<html>
    <body>
        <a href="foo/bar#hash">link</a>
    </body>
</html>
  1. Write the following to ./test/foo/bar/index.html
<!DOCTYPE html>
<html>
    <body>
        <h1 id="hash">Title</h1>
    </body>
</html>
  1. Run htmlproofer on ./test (with no other options)
  2. Hash not exist error(unexpected), as well as without trailing hash(expected) is printed

Expected behavior

(Hash is properly tested, and) Only without trailing hash error is printed.

> bundle exec htmlproofer ./test  
Running 3 checks (Links, Images, Scripts) in ["./test"] on *.html files...


Process.fork is not supported by this Ruby
Ran on 2 files!


For the Links check, the following failures were found:

* In ./test/index.html (line 4):

  internally linking to a directory foo/bar#hash without trailing slash

HTML-Proofer found 1 failure!

Actual behavior

> bundle exec htmlproofer ./test  
Running 3 checks (Links, Images, Scripts) in ["./test"] on *.html files...


Process.fork is not supported by this Ruby
Ran on 2 files!


For the Links check, the following failures were found:

* In ./test/index.html (line 4):

  internally linking to a directory foo/bar#hash without trailing slash

For the Links > Internal check, the following failures were found:

* In ./test/index.html (line 4):

  internally linking to foo/bar#hash; the file exists, but the hash 'hash' does not


HTML-Proofer found 2 failures!

Versions

Operating System: Windows 10 Home 21H2
Ruby: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x64-mingw-ucrt]
html-proofer: 4.0.0.rc3

@gjtorikian
Copy link
Owner

Amazing issue report, thank you so much. I will look at this within the next day or so, I just wanted to say how much I appreciate the thoroughness here.

@gjtorikian
Copy link
Owner

I will look at this within the next day or so

Actually while I set up the test fixtures for this I already found the problem, and have opened #715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants