-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a93fa40
commit c361a0e
Showing
5 changed files
with
163 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
const separatorRegex = /[;,\s]/ | ||
const validRedirectNumRegex = /^[0-9.]+$/ | ||
const separatorRegex = /[;,\s]/; | ||
const validRedirectNumRegex = /^[0-9.]+$/; | ||
|
||
function metaRefreshEvaluate(node, options, virtualNode) { | ||
export default function metaRefreshEvaluate(node, options, virtualNode) { | ||
const content = (virtualNode.attr('content') || '').trim(); | ||
if (!content) { | ||
return true; | ||
} | ||
} | ||
const [redirectStr] = content.split(separatorRegex); | ||
if (!redirectStr.match(validRedirectNumRegex)) { | ||
return true; | ||
} | ||
// Prepend "0" to deal with the ".5" case: | ||
const redirectDelay = parseInt('0' + redirectStr); | ||
const redirectDelay = praseFloat(redirectStr); | ||
this.data({ redirectDelay }); | ||
if (typeof options?.minDelay === 'number' && redirectDelay <= options.minDelay) { | ||
if ( | ||
typeof options?.minDelay === 'number' && | ||
redirectDelay <= options.minDelay | ||
) { | ||
return true; | ||
} | ||
if (typeof options?.maxDelay === 'number' && redirectDelay > options.maxDelay) { | ||
if ( | ||
typeof options?.maxDelay === 'number' && | ||
redirectDelay > options.maxDelay | ||
) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export default metaRefreshEvaluate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
describe('meta-refresh fail', function() { | ||
'use strict'; | ||
|
||
it('should find no matches', function(done) { | ||
axe.run( | ||
{ runOnly: 'meta-refresh' }, | ||
function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 1, 'violations'); | ||
assert.lengthOf(results.passes, 0, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
assert.lengthOf(results.inapplicable, 0, 'inapplicable'); | ||
done(); | ||
} catch (e){ | ||
done(e); | ||
} | ||
it('should be a violation', function(done) { | ||
axe.run({ runOnly: 'meta-refresh' }, function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 1, 'violations'); | ||
assert.lengthOf(results.passes, 0, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
assert.lengthOf(results.inapplicable, 0, 'inapplicable'); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
); | ||
}); | ||
}); | ||
}); |
27 changes: 12 additions & 15 deletions
27
test/integration/full/meta-refresh/meta-refresh-inapplicable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
describe('meta-refresh inapplicable', function() { | ||
'use strict'; | ||
|
||
it('should find no matches', function(done) { | ||
axe.run( | ||
{ runOnly: 'meta-refresh' }, | ||
function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 0, 'violations'); | ||
assert.lengthOf(results.passes, 0, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
assert.lengthOf(results.inapplicable, 1, 'inapplicable'); | ||
done(); | ||
} catch (e){ | ||
done(e); | ||
} | ||
it('should be inapplicable', function(done) { | ||
axe.run({ runOnly: 'meta-refresh' }, function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 0, 'violations'); | ||
assert.lengthOf(results.passes, 0, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
assert.lengthOf(results.inapplicable, 1, 'inapplicable'); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
describe('meta-refresh pass', function() { | ||
'use strict'; | ||
|
||
it('should find no matches', function(done) { | ||
axe.run( | ||
{ runOnly: 'meta-refresh' }, | ||
function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 0, 'violations'); | ||
assert.lengthOf(results.passes, 1, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
done(); | ||
} catch (e){ | ||
done(e); | ||
} | ||
it('should pass', function(done) { | ||
axe.run({ runOnly: 'meta-refresh' }, function(err, results) { | ||
try { | ||
assert.isNull(err); | ||
assert.lengthOf(results.violations, 0, 'violations'); | ||
assert.lengthOf(results.passes, 1, 'passes'); | ||
assert.lengthOf(results.incomplete, 0, 'passes'); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
); | ||
}); | ||
}); | ||
}); |