xrav3nz
13 Settembre 2019, 2:18pm
8
Rispondo qui così che altri abbiano il contesto.
Pensavo fosse strano perché la scheda delle notifiche non condivide lo stesso percorso di rendering degli altri, quindi ho annullato localmente la nuova funzione di accesso rapido e riesco ancora a riprodurre il problema:
Credo che si tratti di un caso estremamente raro con il nostro I18n.t lato client; ecco un test minimo che fallisce per questo: https://github.com/xrav3nz/discourse/commit/3d7324281a285158fe75f9e7b425f9e7b42574906c940e49 .
Risolto con:
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 Mi Piace