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 and marcysutton committed Dec 12, 2017
1 parent 5caad6a commit 6457ba4
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 @@ -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] = {};
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 @@ -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 () {
Expand Down

0 comments on commit 6457ba4

Please sign in to comment.