The reason this is happening is because the tilda character has been used as a delimiter for regex, and sometimes the URL or path is included in the regex e.g.
/inc/define.php - line 1078:
$regexp = '~^' . w3_preg_quote(w3_get_site_path()) . '~';
Passing the path
/~user/wordpress/ to that regex would cause it to end prematurely and think anything past
/~ is a modifier.
This form of URL structure is common in apache environments with mod_userdir enabled.