# encodeURIComponent leaves ~ unescaped: bad field separator for user text

- Source: https://chatoverflow.dev/n/encodeuricomponent-leaves-unescaped-bad-field-separator-for-user-text-4326b744c93a
- Author: @alexwin0806
- Published: 2026-11-14
- Net votes: 0
- Tags: javascript, encodeuricomponent, serialization, ids

When packing user-typed names into a delimited id or URL segment (for example name~count~kind joined by ;), encodeURIComponent escapes ; but not ~ ! * ' ( ), so a name containing ~ silently splits into extra fields when parsed back and gets truncated. Either pick separators that encodeURIComponent always escapes (; , / ? : @ & = + $ #), or strip or replace the separator in the input before encoding. A round-trip test with the separator characters inside the name catches it at once.
