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

Allow skip patterns to match exact filename #33

Open
mojavelinux opened this issue Apr 10, 2020 · 6 comments
Open

Allow skip patterns to match exact filename #33

mojavelinux opened this issue Apr 10, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@mojavelinux
Copy link

There are certain target pages I would like checklinks to skip (which are satisfied by redirect rules). In particular, I want to skip references to the index.html file at the root of my site (related to #20). However, it's currently not possible to differentiate one index.html from another since the skip filter uses "includes" to match the pattern. As a result, when I specify "index.html" in skipPatterns, it ends up skipping references to all filenames anywhere in the site that end in "index.html".

Would it be possible to make the skip pattern more strict? Perhaps if it starts and ends with /, it could be treated as a regular expression? Or if it doesn't contain a glob, it could be matched against the whole filename?

@Munter
Copy link
Owner

Munter commented Apr 17, 2020

What might not be completely clear from the documentation is that the skip pattern matches on the entire value of any of the keys in the tap report. So maybe you can match on /index.html or something else that extends slightly beyond just the file name, which would allow you to specify that it's only the root link that should be skipped.

Does that solve your problem?

@mojavelinux
Copy link
Author

I'm not really sure how that helps me. Consider that there are two pages in the site:

  • /index.html
  • /topic/index.html

No matter what value I use, what will match the first will match the second. So include is simply not sufficient as a skipPattern unless there is a way to indicate an exact match.

@Munter
Copy link
Owner

Munter commented Apr 17, 2020

What you can't properly see in my example is the leading space. The tap report inlines the paths in a sentence, which you can include in your match.

Can you paste an example of the tap failure report?

@mojavelinux
Copy link
Author

Aha! I did not see the leading space. I see what you mean now.

I wouldn't say that's a very robust solution since it relies on the sentence structure, though it does at least give me a workaround until it breaks.

@Munter
Copy link
Owner

Munter commented Apr 17, 2020

It might make sense to add the root-relative url for local assets and the absolute url for external ones in a separate field so you can explicitly match on them. The trick is that a link to an asset can fail due to multiple reasons, and then you'd need to both check this path and the reason in order to construct a filter match. Doable programmatically, not so much as a command line argument without inventing new syntax.

I'll think a bit about if this is one of the cases where the CLI is actually reducing the utility of the netlify plugin, because you can indeed define structured data to match on multiple properties in the netlify config

@Munter Munter added the enhancement New feature or request label Apr 17, 2020
@mojavelinux
Copy link
Author

@Munter I'd like to report that your workaround did work for me.

The reason I need the workaround is because the page to which I'm linking is provided by a Netlify redirect. In this case, it's the /index.html page of the site, which redirects to another page deeper within the site. checklinks reports that links to /index.html are broken, when in fact I know they are not. Now I have a way to exclude these links without excluding all links to a URL within the site that ends with /index.html (which includes many pages).

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

No branches or pull requests

2 participants