pa11y / pa11y-ci

Pa11y CI is a CI-centric accessibility test runner, built using Pa11y
https://pa11y.org
GNU Lesser General Public License v3.0
515 stars 63 forks source link

Using `--sitemap-exclude` command-line option. #182

Closed 1jasgithub closed 1 year ago

1jasgithub commented 2 years ago

Hello, how would I include the '--sitemap-exclude' command-line option with our website?

pa11y-ci keeps failing on pdfs.

I see this line in package.json "pa11y-ci:sitemap": "pa11y-ci --sitemap http://localhost:4000/sitemap.xml --sitemap-exclude \"/*.pdf\" --sitemap-exclude \"/admin\""

but not sure how to use it to exclude the pdf? (I'm a new user) Thanks! Jas

josebolos commented 2 years ago

Hi @1jasgithub!

The code for excluding URLs from the testing uses a simple regular expression, so you should be able to pass any valid regular expression and pa11y-ci will match all the URLs in the sitemap against the regexp.

As what you're passing as an argument to pa11y is a regex, the character * in your command will be interpreted as "zero or more instances of the previous token" rather than a pathname wildcard. Something like the following should work to exclude PDFs:

pa11y-ci --sitemap 'http://localhost:4000/sitemap.xml' --sitemap-exclude '\.pdf$'