stevenvachon / broken-link-checker

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

Cannot make it work on the filesystem #194

Closed raimohanska closed 4 years ago

raimohanska commented 4 years ago

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);
stevenvachon commented 4 years ago

Not implemented.

raimohanska commented 4 years ago

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?

raimohanska commented 4 years ago

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