ChrisWren / grunt-link-checker

Run node-simple-crawler to discover broken links on your website
MIT License
33 stars 9 forks source link

Possible to add an ignore / whitelist for accepted errors? #10

Closed made-by-chris closed 9 years ago

made-by-chris commented 10 years ago

It would be nice to be able to whitelist a bunch of URLs which are expected to break for a number of reasons: dynamic-template URLS, hacky graceful fallbacks code etc.

Can i somehow do this with the current implementation?

danken00 commented 10 years ago

It's possible to narrow down which URLs are crawled by taking advantage of the SimpleCrawler options. For instance, some JS files were throwing errors that I wasn't interested in, so I removed these from the URLs being crawled:

'link-checker': {
    postDeploy: {
        site: 'mydomain.com',
            options: {
                callback: function (crawler) {
                    crawler.addFetchCondition(function (url) {
                        return !url.path.match(/\.js$/i);
                    });
                }
            }
        }
    }

More reading and options: https://github.com/cgiffard/node-simplecrawler#excluding-certain-resources-from-downloading

ChrisWren commented 9 years ago

@danken00 thanks for responding to this!

danken00 commented 9 years ago

Pleasure. Thanks for writing the plugin :)