stevenvachon/broken-link-checker

Cannot make it work on the filesystem

raimohanska opened this issue · 3 comments

I'm trying to check a static site on the filesystem. It seems that relative links using the file:// scheme are always reported broken. Is this even a supported mode of operation?

This is how I use it:

const {HtmlChecker} = require('broken-link-checker');
const fs =require("fs")
const path =require("path")

const articleRoot = path.resolve(rootFolderForMyStuf)
const indexHtml = fs.readFileSync(`${articleRoot}/index.html`, "utf-8")
const baseUrl = "file://" + articleRoot + "/"

const htmlChecker = new HtmlChecker(
    {
        acceptedSchemes: ["http", "https", "file"]
    },
    {
        link: (arg) => { console.log("Link", arg.broken, arg.brokenReason)},
        complete: (arg) => { console.log("Complete") }
    }
)

htmlChecker.scan(indexHtml, baseUrl);

Not implemented.

I understand. This would be highly useful though. Would you care to merge a Pull Request just in case I decided to give this a try? Are there any fundamental issues that would prevent me from doing this?

Alternatively, if there's an existing tool for the job of checking a site in the filesystem, I'd be interested in finding it :)