I've submitted an upstream PR, so I can reference that in the comment and simplify it slightly.
Attach a file by drag & drop or click to upload