You are correct. I already pushed a fix for this problem in this PR:
https://github.com/discourse/discourse/pull/16408