Skip to content

Commit

Permalink
fix(helpUrl): Properly parse x.0 versions (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers authored Sep 27, 2017
1 parent 19d7f97 commit a51c5ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,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] = {};
Expand Down
16 changes: 16 additions & 0 deletions test/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,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 () {
Expand Down

0 comments on commit a51c5ce

Please sign in to comment.