Here’s a fix for this:
https://github.com/discourse/discourse/commit/d0741f752ffd72f4529070b00ff974fef434e277