This has been fixed with this change:
https://github.com/discourse/discourse/commit/574028bff8e1501d0003ef931c7e071173a9d96a