Skip to content

Commit a51c5ce

Browse files
authored
fix(helpUrl): Properly parse x.0 versions (#550)
1 parent 19d7f97 commit a51c5ce

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/core/base/audit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function getHelpUrl ({brand, application}, ruleId, version) {
299299
}
300300

301301
Audit.prototype._constructHelpUrls = function (previous = null) {
302-
var version = (axe.version.match(/^[1-9][0-9]*\.[1-9][0-9]*/) || ['x.y'])[0];
302+
var version = (axe.version.match(/^[1-9][0-9]*\.[0-9]+/) || ['x.y'])[0];
303303
this.rules.forEach(rule => {
304304
if (!this.data.rules[rule.id]) {
305305
this.data.rules[rule.id] = {};

test/core/base/audit.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ describe('Audit', function () {
184184
assert.equal(audit.data.rules.target.helpUrl,
185185
'https://dequeuniversity.com/rules/axe/x.y/target?application=axeAPI');
186186
});
187+
it('matches major release versions', function () {
188+
var tempVersion = axe.version;
189+
var audit = new Audit();
190+
audit.addRule({
191+
id: 'target',
192+
matches: 'function () {return "hello";}',
193+
selector: 'bob'
194+
});
195+
196+
axe.version = '1.0.0';
197+
audit._constructHelpUrls();
198+
199+
axe.version = tempVersion;
200+
assert.equal(audit.data.rules.target.helpUrl,
201+
'https://dequeuniversity.com/rules/axe/1.0/target?application=axeAPI');
202+
});
187203
});
188204

189205
describe('Audit#setBranding', function () {

0 commit comments

Comments
 (0)