Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture Screen Per URL in a sitemap #74

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
15 changes: 15 additions & 0 deletions bin/pa11y-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ function defaultConfig(config) {
return config;
}

// Generate a file name string from url
function getFileNameFromUrl(url) {
return url.trim('/').split('/').join('-').replace('.', '').replace(':', '');
umutphp marked this conversation as resolved.
Show resolved Hide resolved
}

// Load a sitemap from a remote URL, parse out the
// URLs, and add them to an existing config object
function loadSitemapIntoConfig(program, config) {
Expand Down Expand Up @@ -235,6 +240,16 @@ function loadSitemapIntoConfig(program, config) {
if (sitemapFind) {
url = url.replace(sitemapFind, sitemapReplace);
}

// If default screenCapture is set, the screen captured per url in sitemap.
// The filename should be like /abs/path/to/filename.png, the "filename" is replaced.
if (config.defaults.screenCapture) {
url = {
url: url,
screenCapture: config.defaults.screenCapture.replace('filename', getFileNameFromUrl(url))
};
}

config.urls.push(url);
});

Expand Down