
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
grunt-check-pages
Advanced tools
Grunt task that checks various aspects of a web page for correctness.
Grunt task that checks various aspects of a web page for correctness.
This plugin requires Grunt ~0.4.4
or later.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-check-pages --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-check-pages');
For similar functionality without a Grunt dependency, please see the check-pages
package.
For direct use, the check-pages-cli
package wraps check-pages
with a command-line interface.
An important aspect of creating a web site is validating the structure, content, and configuration of the site's pages. The checkPages
task provides an easy way to integrate this testing into your normal Grunt workflow.
By providing a list of pages to scan, the task can:
In your project's Gruntfile, add a section named checkPages
to the data object passed into grunt.initConfig()
.
The following example includes all supported options:
grunt.initConfig({
checkPages: {
development: {
options: {
pageUrls: [
'http://localhost:8080/',
'http://localhost:8080/blog',
'http://localhost:8080/about.html'
],
checkLinks: true,
linksToIgnore: [
'http://localhost:8080/broken.html'
],
noEmptyFragments: true,
noLocalLinks: true,
noRedirects: true,
onlySameDomain: true,
preferSecure: true,
queryHashes: true,
checkCaching: true,
checkCompression: true,
checkXhtml: true,
summary: true,
terse: true,
maxResponseTime: 200,
userAgent: 'custom-user-agent/1.2.3'
}
},
production: {
options: {
pageUrls: [
'http://example.com/',
'http://example.com/blog',
'http://example.com/about.html'
],
checkLinks: true,
maxResponseTime: 500
}
}
}
});
Type: Array
of String
Default value: undefined
Required
pageUrls
specifies a list of URLs for web pages the task will check. The list can be empty, but must be present. Wildcards are not supported.
URLs can point to local or remote content via the http
, https
, and file
protocols. http
and https
URLs must be absolute; file
URLs can be relative. Some features (for example, HTTP header checks) are not available with the file
protocol.
To store the list outside Gruntfile.js
, read the array from a JSON file instead: pageUrls: grunt.file.readJSON('pageUrls.json')
.
Type: Boolean
Default value: false
Enabling checkLinks
causes each link in a page to be checked for validity (i.e., an HTTP HEAD or GET request returns success).
For efficiency, a HEAD
request is made first and a successful result validates the link. Because some web servers misbehave, a failed HEAD
request is followed by a GET
request to definitively validate the link.
The following element/attribute pairs are used to identify links:
a
/href
area
/href
audio
/src
embed
/src
iframe
/src
img
/src
img
/srcset
input
/src
link
/href
object
/data
script
/src
source
/src
source
/srcset
track
/src
video
/src
video
/poster
Type: Array
of String
Default value: undefined
Used by: checkLinks
linksToIgnore
specifies a list of URLs that should be ignored by the link checker.
This is useful for links that are not accessible during development or known to be unreliable.
Type: Boolean
Default value: false
Used by: checkLinks
Set this option to true
to fail the task if any links contain an empty fragment identifier (hash) such as <a href="#">
.
This is useful to identify placeholder links that haven't been updated.
Type: Boolean
Default value: false
Used by: checkLinks
Set this option to true
to fail the task if any links to localhost
are encountered.
This is useful to detect temporary links that may work during development but would fail when deployed.
The list of host names recognized as localhost
are:
127.0.0.0/8
address block)Type: Boolean
Default value: false
Used by: checkLinks
Set this option to true
to fail the task if any HTTP redirects are encountered.
This is useful to ensure outgoing links are to the content's canonical location.
Type: Boolean
Default value: false
Used by: checkLinks
Set this option to true
to block the checking of links on different domains than the referring page.
This is useful during development when external sites aren't changing and don't need to be checked.
Type: Boolean
Default value: false
Used by: checkLinks
Set this option to true
to fail the task if any HTTP links are present where the corresponding HTTPS link is also valid.
This is useful to ensure outgoing links use a secure protocol wherever possible.
Type: Boolean
Default value: false
Used by: checkLinks
Set this option to true
to verify links with file hashes in the query string point to content that hashes to the expected value.
Query hashes can be used to invalidate cached responses when leveraging browser caching via long cache lifetimes.
Supported hash functions are:
Type: Boolean
Default value: false
Enabling checkCaching
verifies the HTTP Cache-Control
and ETag
response headers are present and valid.
This is useful to ensure a page makes use of browser caching for better performance.
Type: Boolean
Default value: false
Enabling checkCompression
verifies the HTTP Content-Encoding
response header is present and valid.
This is useful to ensure a page makes use of compression for better performance.
Type: Boolean
Default value: false
Enabling checkXhtml
attempts to parse each URL's content as XHTML and fails if there are any structural errors.
This is useful to ensure a page's structure is well-formed and unambiguous for browsers.
Type: Boolean
Default value: false
Enabling the summary
option logs a summary of each issue found after all checks have completed.
This makes it easy to pick out failures when running tests against many pages. May be combined with the terse
option.
Type: Boolean
Default value: false
Enabling the terse
option suppresses the logging of each check as it runs, instead displaying a brief overview at the end.
This is useful for scripting or to reduce output. May be combined with the summary
option.
Type: Number
Default value: undefined
maxResponseTime
specifies the maximum amount of time (in milliseconds) a page request can take to finish downloading.
Requests that take more time will trigger a failure (but are still checked for other issues).
Type: String
Default value: grunt-check-pages/x.y.z
userAgent
specifies the value of the HTTP User-Agent
header sent with all page/link requests.
This is useful for pages that alter their behavior based on the user agent. Setting the value null
omits the User-Agent
header entirely.
checkLinks
and checkXhtml
.maxResponseTime
option, buffer all page responses, add "no-cache" header to requests.checkCaching
and checkCompression
options, improve error handling, use gruntMock
.userAgent
option, weak entity tags, update nock
dependency.noLocalLinks
option, rename disallowRedirect
option to noRedirects
, switch to ESLint
, update superagent
and nock
dependencies.queryHashes
option for CRC-32/MD5/SHA-1, update superagent
dependency.onlySameDomainLinks
option to onlySameDomain
, fix handling of redirected page links, use page order for links, update all dependencies.noRedirects
option, switch to crc-hash
dependency.summary
option, update crc-hash
, grunt-eslint
, nock
dependencies.superagent
to request
, update grunt-eslint
and nock
dependencies.check-pages
package.noEmptyFragments
option, update dependencies.preferSecure
option, terse
option, srcset
, update dependencies.FAQs
Grunt task that checks various aspects of a web page for correctness.
The npm package grunt-check-pages receives a total of 12 weekly downloads. As such, grunt-check-pages popularity was classified as not popular.
We found that grunt-check-pages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.