Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions link-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ module.exports = function(directory, options = {}, callback) {
: typeof target === "object" ? target.request.url // superagent response
: typeof target === "string" ? target // plain URL
: null

const matchingPattern = Array.from(options.overrides.keys()).find(
pattern => pattern.exec(url)
)

if(!matchingPattern) return options

return {...options, ...options.overrides.get(matchingPattern)}

const opts = {...options, ...options.overrides.get(matchingPattern)}
return opts
}

walker(directory, function(filePath, fileContent) {
Expand Down Expand Up @@ -182,13 +184,16 @@ module.exports = function(directory, options = {}, callback) {

// decode anchors
const splitted = href.split('#')
var resolvedHref
if (splitted.length == 2) {
const url = splitted[0]
const anchor = splitted[1]
href = url + '#' + urlencode.decode(anchor)
resolvedHref = path.join(path.dirname(filePath), url) + '#' + urlencode.decode(anchor)
} else {
resolvedHref = path.join(path.dirname(filePath), href)
}

const resolvedHref = path.join(path.dirname(filePath), href)
debug('text content for ' + resolvedHref, $this.html())
if (href.indexOf('http://') == 0 || href.indexOf('https://') == 0) {
if (href.indexOf('#') == -1) {
Expand Down
Loading