ChrisWren / grunt-link-checker

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

Anchors throwing 404s #11

Closed danken00 closed 9 years ago

danken00 commented 9 years ago

I've got a few anchors on my page, and when links to those anchors are being followed, they're getting marked as 404s. A typical example:

<a href="#fast-service" id="fast-service-link" title="Fast service times">Fast service times</a>

As a link to:

<div class="hiccup-right light-grey how-we-are-here-panel" id="fast-service"></div>

And the error:

Resource not found linked from https://[mydomain]/about-us to https://[mydomain]/about-us#fast-service
Status code: 404

Is this expected behaviour?

sgaestel commented 9 years ago

Hi,

I am having the exact same issue on my side. Did you find the root cause as you closed your issue ?

Thanks

danken00 commented 9 years ago

hi @sgaestel, this was a while ago so I had to go back through my notes. See if the setting below helps:

'link-checker': {
    postDeploy: {
        site: 'www.mysite.com',
            options: {
                callback: function (crawler) {
                    crawler.addFetchCondition(function (url) {
                        return !url.path.match(/\.js|#.+$/i); // Ignore JS and anchor links
                    });
                }}
            }
        }

I should've commented on it when I closed it - sorry about that!