Avoid TypeError when accessing matches

Accessing length on matches may cause a TypeError if matches isn't an array.

Maybe I'm using the directive wrong, but occasionally, I'll run into this issue and get `TypeError: Cannot read property 'length' of undefined`.