axe-sarif-converter
Version:
Convert axe-core accessibility scan results to the SARIF format
29 lines (28 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnvironmentDataFromResults = getEnvironmentDataFromResults;
exports.getEnvironmentDataFromEnvironment = getEnvironmentDataFromEnvironment;
function getEnvironmentDataFromResults(axeResults) {
return {
timestamp: axeResults.timestamp,
targetPageUrl: axeResults.url,
axeVersion: axeResults.testEngine.version,
};
}
function getEnvironmentDataFromEnvironment() {
// We use the global "axe" object to detect this rather than saying
// "import { version } from 'axe-core'"" because we want to pick up the
// version of axe that is invoking us, which will usually be a *peer*
// dependency, rather than using the version that axe-sarif-converter built
// against as a child dependency.
var globalAxeVersion = global.axe && global.axe.version;
if (!globalAxeVersion) {
throw Error('Could not infer axe version from global axe object. Are you running from the context of an axe reporter?');
}
return {
timestamp: new Date().toISOString(),
targetPageUrl: window.location.href,
targetPageTitle: document.title,
axeVersion: globalAxeVersion,
};
}