xrav3nz
Setembro 13, 2019, 2:18pm
8
Respondendo aqui para que outros tenham o contexto.
Achei isso estranho porque a aba de notificações não compartilha o mesmo caminho de renderização que as outras, então reverti localmente o novo recurso de acesso rápido e ainda consigo reproduzir o problema:
Acredito que se trate de um caso extremamente específico relacionado ao nosso I18n.t no lado do cliente, e aqui está um teste mínimo que falha para isso: https://github.com/xrav3nz/discourse/commit/3d7324281a285158fe75f9e7b42574906c940e49 .
Corrigido com:
master ← xrav3nz:fix/i18n-js-edge-case
merged 05:52PM - 16 Sep 19 UTC
> Context: https://meta.discourse.org/t/notification-character-bug/128461/8
I… was almost pulling my hairs out wondering why this would happen, then I took a closer look at [the `replace(pattern, replacement)` function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter):
> The `replacement` string can include the following special replacement patterns:
>
> Pattern | Inserts
> -- | --
> $& | Inserts the matched substring.
> ... | ...
The dollar sign (`$`) is a special replace pattern, and `$&` inserts the matched string... 😅 Thus dollars signs need to be escaped with the special pattern `$$`, which inserts a single `$`.
Let me know what you think, thanks!
9 curtidas