UNPKG

755 BJavaScriptView Raw
1import RSVP from 'rsvp';
2import a11yAudit from './audit';
3import utils from './utils';
4
5/**
6 * A method to return the value of queryParameter
7 *
8 * @method getUrlParameter
9 * @private
10 */
11function getUrlParameter(name) {
12 const location = utils.getLocation();
13 const regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
14 const results = regex.exec(location.search);
15 return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
16}
17
18/**
19 * A wrapper method to run the a11yAudit if desired
20 *
21 * @method a11yAuditIf
22 * @public
23 */
24export default function a11yAuditIf(...args) {
25 if(getUrlParameter('enableA11yAudit') === 'true') {
26 return a11yAudit(...args);
27 }
28
29 return RSVP.resolve(undefined, 'a11y audit not run');
30}