Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #267 from 18F/uswds-presence
Browse files Browse the repository at this point in the history
Start attempting to measure USWDS presence
  • Loading branch information
IanLee1521 authored Sep 17, 2018
2 parents 02b6278 + 929bde8 commit 2b00690
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion scanners/uswds.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,27 @@ module.exports = {
else throw exc;
}

// Do a quick text match on the HTML to find out of date USWDS
// banner text.
const html = await page.content();

data.banner_bad_text = hasBadText(html);

// Search DOM for evidence of USWDS being present at all.
data.present = await uswdsPresent(page);

return data;
}
}

// Simple text match on some old text.
var hasBadText = (html) => {
return (html.search("Federal government websites always use a .gov or .mil domain.") >= 0)
};


// Checks for any element with a class with "usa-" in it.
// TODO: Should "usa-" at least be at the start of the string?
var uswdsPresent = async (page) => {
var match = await page.$('[class*=usa-]');
return (match != null);
};
4 changes: 2 additions & 2 deletions scanners/uswds.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def to_rows(data):

return [[
data['url'],
data.get('banner_present'),
data.get('present'),
data.get('banner_bad_text'),
]]


headers = [
'Scanned URL',
'USWDS Banner Present',
'USWDS Present',
'USWDS Bad Banner Text'
]

0 comments on commit 2b00690

Please sign in to comment.