link-check
Advanced tools
Comparing version
# Changes | ||
## Version 5.1.0 | ||
Changes: | ||
* support for hash links | ||
## Version 5.0.3 | ||
@@ -4,0 +10,0 @@ |
@@ -6,2 +6,3 @@ "use strict"; | ||
const protocols = { | ||
hash: require('./lib/proto/hash'), | ||
file: require('./lib/proto/file'), | ||
@@ -21,4 +22,4 @@ http: require('./lib/proto/http'), | ||
const url = new URL(link, opts.baseUrl); | ||
const protocol = url.protocol.replace(/:$/, ''); | ||
const url = link.startsWith('#') ? link : new URL(link, opts.baseUrl); | ||
const protocol = link.startsWith('#') ? 'hash' : url.protocol.replace(/:$/, ''); | ||
@@ -25,0 +26,0 @@ if (!protocols.hasOwnProperty(protocol)) { |
{ | ||
"name": "link-check", | ||
"version": "5.0.3", | ||
"version": "5.1.0", | ||
"description": "checks whether a hyperlink is alive (200 OK) or dead", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -31,2 +31,3 @@  | ||
* `opts` optional options object containing any of the following optional fields: | ||
* `anchors` array of anchor strings (e.g. `[ "#foo", "#bar" ]`) for checking anchor links (e.g. `<a href="#foo">Foo</a>`). | ||
* `baseUrl` the base URL for relative links. | ||
@@ -33,0 +34,0 @@ * `timeout` timeout in [zeit/ms](https://www.npmjs.com/package/ms) format. (e.g. `"2000ms"`, `20s`, `1m`). Default `10s`. |
@@ -491,2 +491,18 @@ 'use strict'; | ||
it('should support hash links', function (done) { | ||
linkCheck('#foo', { anchors: ['#foo'] }, function (err, result) { | ||
expect(err).to.be(null); | ||
expect(result.err).to.be(null); | ||
expect(result.status).to.be('alive'); | ||
expect(result.statusCode).to.be(200); | ||
linkCheck('#bar', { anchors: ['#foo'] }, function (err, result) { | ||
expect(err).to.be(null); | ||
expect(result.err).to.be(null); | ||
expect(result.status).to.be('dead'); | ||
expect(result.statusCode).to.be(404); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
36391
3.45%17
6.25%632
3.95%87
1.16%