Removing homeomorphic connected components Suppose that topological spaces $X$ and $Y$ are homeomorphic, and let $C_1 \subset X$ and $C_2 \subset Y$ be connected components in each of the respective spaces, so that $C_1$ is homeomorphic to $C_2$ with the subspace topologies. Is it true that $X \setminus C_1$ is homeomorphic to $Y \setminus C_2$ ?
My thoughts: if $f: X \mapsto Y$ is an homeomorphism, then it maps connected components to connected components. We have two possibilities: if $f(C_1) = C_2$ then $f|_{X \setminus C_1}$ is the desired homeomorphism. Otherwise, let $C_3 \subset X$ and $C_4 \subset Y$ be the components such that $f(C_1) = C_4$, $f(C_3) = C_2$ and $C_1 \neq C_3$, $C_2 \neq C_4$. Define $h: X \setminus C_1 \mapsto Y \setminus C_2$ as:
$$h(x) = \begin{cases} x & x \notin C_3 \\ f(g(f(x))) & x \in C_3
\end{cases},$$
where $g : C_2 \mapsto C_1$ is an homeomorphism. The resulting map $h$ is well defined and bijective, maps connected components to connected components and restricts to an homeomorphism in each connected component. Does this suffice to conclude that $h$ is an homeomorphism?
With respect to this latter question, I think that you can take an open set $U \subset Y \setminus C_2$, which is just any open subset in $Y$ since $Y \setminus C_2$ is open, and one has $h^{-1}(U) = \bigcup_{j}h^{-1}(U) \cap X_j = \bigcup_{j}h^{-1}(U \cap Y_j)$, where $X_j$ are the connected components of $X \setminus C_1$ and $Y_j = h(X_j)$ those of $Y \setminus C_2$, but every $h^{-1}(U \cap Y_j)$ is open in $X_j$ since $U \cap Y_j$ is open in $Y_j$ (since $h$ restricted to an homeomorphism on each component), and being open in a connected component amounts to being open in the whole space, so $h^{-1}(U)$ is a union of open sets in $X \setminus C_1$ and so it's open.
This seems correct and intuitive to me, but I couldn't find anything about this result to double-check. Thanks in advance.
 A: This question was solved some time ago in the comment section of the original post, with the insights from commenters Randall and Rob Arthan, that I will summarize here.
The proposition (which ammounted to showing that a bijective mapping which restricts to a homeomorphism in each connected component is a homeomorphism as a whole) turns out to be true if the connected components of the original space, $X$, are open. This is to ensure the correctness of: "being open in a connected component ammounts to being open in the whole space", which I used in my original line of reasoning.
Having open connected components is implied by several other assertions, such as being locally connected or having finitely many connected components (since connected components are always closed).
As for a counterexample when connected components are not open, Rob Arthan gave the following one: consider $X = Y = \mathbb S^1 \sqcup (\mathbb Q \times \mathbb S^1)$, $C_1 = \mathbb S^1$ and $C_2 = \{0\} \times \mathbb S^1$. Obviously $C_1 \simeq C_2$, but $X \setminus C_1 = \mathbb Q \times \mathbb S^1$, while $Y \setminus C_2 = \mathbb S^1 \sqcup (\mathbb Q \setminus \{0\} \times \mathbb S^1)$, which cannot be homeomorphic because $\mathbb S^1 \subset Y \setminus C_2$ is a connected, open subset, but there are no such sets in $X \setminus C_1$.
