From 3fe72ddbff6975341d7c5d255a9c2e26833de8d4 Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Wed, 27 Sep 2017 12:35:07 +0200 Subject: [PATCH] fix(helpUrl): Properly parse x.0 versions (#550) --- lib/core/base/audit.js | 2 +- test/core/base/audit.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/core/base/audit.js b/lib/core/base/audit.js index 055f78f12c..1ee559f205 100644 --- a/lib/core/base/audit.js +++ b/lib/core/base/audit.js @@ -297,7 +297,7 @@ function getHelpUrl ({brand, application}, ruleId, version) { } Audit.prototype._constructHelpUrls = function (previous = null) { - var version = (axe.version.match(/^[1-9][0-9]*\.[1-9][0-9]*/) || ['x.y'])[0]; + var version = (axe.version.match(/^[1-9][0-9]*\.[0-9]+/) || ['x.y'])[0]; this.rules.forEach(rule => { if (!this.data.rules[rule.id]) { this.data.rules[rule.id] = {}; diff --git a/test/core/base/audit.js b/test/core/base/audit.js index cc52a98130..50758bbca9 100644 --- a/test/core/base/audit.js +++ b/test/core/base/audit.js @@ -181,6 +181,22 @@ describe('Audit', function () { assert.equal(audit.data.rules.target.helpUrl, 'https://dequeuniversity.com/rules/axe/x.y/target?application=axeAPI'); }); + it('matches major release versions', function () { + var tempVersion = axe.version; + var audit = new Audit(); + audit.addRule({ + id: 'target', + matches: 'function () {return "hello";}', + selector: 'bob' + }); + + axe.version = '1.0.0'; + audit._constructHelpUrls(); + + axe.version = tempVersion; + assert.equal(audit.data.rules.target.helpUrl, + 'https://dequeuniversity.com/rules/axe/1.0/target?application=axeAPI'); + }); }); describe('Audit#setBranding', function () {