This is now fixed:
https://github.com/discourse/discourse/commit/7da875f52aaf2545a2967c0dc42675372f316a75