Though I would go with `if (filepath[0] === '~') {`