stevenvachon / broken-link-checker

Find broken links, missing images, etc within your HTML.
MIT License
1.95k stars 302 forks source link

API: includedKeywords does not work #235

Open banner-prog opened 3 years ago

banner-prog commented 3 years ago

The option includedKeywords does not work. The tool will scan for all links even when you want to scan links with only specific keywords.

matkoniecz commented 3 years ago

Can you give specific examples?

banner-prog commented 3 years ago

Like, if I want to scan for broken links of facebook.com and github.com, I am meant to use the option includedKeywords. However, even if I use that, the tool will scan and give results of broken links such as example.com or instagram.com

matkoniecz commented 3 years ago

please give exact runnable code/command that triggers this bug - it needs to be done as the first step of resolving this bug

banner-prog commented 3 years ago

Here is the code

var { SiteChecker } = require("broken-link-checker");
var URL = "https://www.github.com"
const siteChecker = new SiteChecker(
    { 
        excludeInternalLinks: true,
        excludeExternalLinks: false, 
        filterLevel: 1,
        acceptedSchemes: ["http", "https"],
        excludedKeywords: ["linkedin.com"],
        includedKeywords: ["facebook.com","instagram.com"],

    },
    {
        "error": (error) => {
            console.error(error);

        },

        "link": (result, customData) => {
            if(result.broken) {
                if(result.http.response && ![undefined, 200].includes(result.http.response.statusCode)) {
                    console.log(`${result.base.original} => ${result.url.original}`);
                }
            }            

        },

        "end": () => {
            console.log("COMPLETED!");
        }
    }
);

siteChecker.enqueue(URL);