-
Notifications
You must be signed in to change notification settings - Fork 53
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
Ignore internal urls #169
Ignore internal urls #169
Conversation
Hello, Any news for this PR ? Is there something more that you need ? |
Hey @divinerites sorry for the delay on this. I'm away the rest of this week, will try and get to this next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @divinerites sorry for the delay here.
This change looks good. I was mostly pondering over the new config name as once published these can't really be changed as they end up in in users' configs. I think I'm happy with IgnoreInternalURLs
though. Pity I didn't have the forethought needed to name IgnoreURLs
better.
My other thought is if we could combine IgnoreURLs
and IgnoreInternalURLs
though this would likely add more complexity: how would you decide what was internal vs external given that an internal doesn't always start with a slash?
Another thought: an improvement to this feature could be understanding the path of the internal URL such that the following works:
- Ignore
/misc/js/script.js
- Link to
js/script.js
inside/misc/page.html
is ignored
For the first pass of this feature though this probably is going too far.
I don't think we should do either of these now, just wonder if you have any thoughts.
One thing I'd like to see added before merging is a test of this running on an HTML file. One test where the issue is raised without setting IgnoreInternalURLs
and one where it is ignored with the config set. This belongs in check-link_test.go
alongside the TestAnchorInternal
tests.
Thanks!
Co-authored-by: Will Pimblett <will@wjdp.uk>
@wjdp thanks for your comments.
Regarding your request for "test of this running on an HTML file", I'll look if i can, but I'm afraid this is not in my go skills. |
@divinerites Have a look at the existing tests, it should be straightforward:
There's many examples of this, like: func TestAnchorDirectoryNoTrailingSlash(t *testing.T) {
// fails for internal linking to a directory without trailing slash
hT := tTestFile("fixtures/links/link_directory_without_slash.html")
tExpectIssueCount(t, hT, 1)
tExpectIssue(t, hT, "target is a directory, href lacks trailing slash", 1)
}
func TestAnchorDirectoryNoTrailingSlashOption(t *testing.T) {
// passes for internal linking to a directory without trailing slash when asked
hT := tTestFileOpts("fixtures/links/link_directory_without_slash.html",
map[string]interface{}{"IgnoreDirectoryMissingTrailingSlash": true})
tExpectIssueCount(t, hT, 0)
} |
@wjdp I've done it. |
OK. I understood better how to run test. Corrected some wrong syntax. Tests seems OK except one :
|
OK. All test PASS now. Sorry for being so slow, but this is quite new to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tests are now PASSING fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the tests!
Cool, thanks @divinerites and @wjdp! |
Hello,
Following #168 I made a small patch.
It seems that for this use case, we cannot use the
IgnoreURLs
because it uses regexp and this is I think too violent for internal urls.So I added the internal equivalent
IgnoreInternalURLs
and just done an equal test for url.Seems to work fine for what I tested.
I also added some tests, but as said I'm a golang noob, so I don't know if those tests suits your quality needs. may be you have to add/reinforce those tests.
Hope this is helpful.
Done with go version go1.16 darwin/amd64
Solve #168