This is now in core
https://github.com/discourse/discourse/commit/c29e72280157a0b844657b42d441ebb577117d6b