Any rational map can be extended to codimension one. If I understand correctly:
Given a rational map $f$, between two (smooth) varieties $X$ and $Y$, with indeterminacy locus $\Sigma$ of codimension 1 in $X$, then $f$ can be extended to a regular map $X\rightarrow Y$. How is this done?
Elaboration and/or reference for this beautiful phenomenon would be much appreciated. 
Edit: As Asal's answer suggests below, I had a misunderstanding. My question originated from the following concrete example: let $X$ be a smooth cubic surface in space, containing a line $\ell$. Consider the pencil of conics on $X$ obtained by residual intersection of $X$ and the $\Bbb{P}^1$ of planes containing $\ell$. This yields a regular map $f:X\setminus\ell\rightarrow\Bbb{P}^1$. The questions are:


*

*is there a general result guaranteeing that $f$ can be extended to $X$ ?

*geometrically, how would the extension be defined on $\ell$ ?


Another way to look at this example is the following situation: assume that on a smooth surface $X$ we have a complete linear system written in mobile and fixed part decomposition as $|L|=|M|+F$. (In our example $|M|$ is the pencil of conics and $F=\ell$). Assume $|M|$ is basepoint free. Then we get a regular map $X\setminus F\rightarrow\Bbb{P}^N$. To my understanding, then we can always extend this morphism to $F$ as well. Is this statement correct (why) ?
 A: The statement you have written is not correct, for several reasons. 
There are two related (true) theorems, which I'll state now. (Both can be found in Shafarevich Chapter II --- I don't have the book to hand, so I can't give precise references.) 
Theorem A: Let $f: X \dashrightarrow \mathbf A^1$ be a rational function on a smooth variety $X$. If $X$ is regular along every codimension-1 subvariety $Y \subset X$, then $X$ is regular. 
Sketch of proof: Everything is local on $X$, so we can assume $X$ is affine, embedded in some $\mathbf A^n$. Then $f=g/h$ for some polynomials $g$ and $h$ with no common factor. The indeterminacy locus of $f$ is then the zero locus of $h$, which is either empty or codimension 1 in $X$. $\ \square$
Theorem B: Let $f: X \dashrightarrow \mathbf P^m$ be a rational map from a smooth variety $X$ to projective space. Then the indeterminacy locus of $f$ has codimension at least 2 in $X$.
Sketch of proof: Let's stick to the case $m=1$ for simplicity of notation; the general case works in the same way. Reducing to the affine case as above, we can write $f$ as $[g,h]$ where $g$ and $h$ are polynomials. If $g$ and $h$ have a common factor we can remove it, so again we may assume they don't. The indeterminacy locus of $f$ is $\{g=0\} \cap \{h=0\}$, which therefore has codimension at least 2 in $X$. $\ \square$
It seems as though you somehow mixed up these two theorems. 
Let me close with a couple of remarks:


*

*Theorems A and B almost seem to be in conflict with each other! The key point to notice is that in Theorem B we are talking about a map to projective space. Roughly speaking, in this case there are "more places" for the codimension-1 subsets of $X$ to map to, hence less indeterminacy. 

*Neither Theorem A nor B is true without some hypotheses on the singularities of $X$. (I assumed "smooth" for simplicity; you can check that "normal" would also suffice.) For example, let $C$ be a nodal cubic curve and $n: \mathbf P^1 \rightarrow C$ its normalisation. Then Theorem B fails for the rational map $n^{-1}$. (A counterexample for Theorem A is a bit harder to find!) 
Update: This addresses the extra questions that the OP added later. If the linear system $|L|$ decomposes into mobile and fixed part as $|M|+F$, then we extend it to all codimension-1 points by simply "forgetting" about $F$. That is: outside $F$, the maps given by $|L|$ and $|M|$ are the same, so the map given by $|M|$ extends that given by $|L|$. Since $|M|$ is mobile, it has no fixed components, so the corresponding map only fails to be defined in codimension 2. 
(I note that none of this is specific to surfaces. One thing that is specific to surfaces is that a mobile linear system has finite base locus, and such a complete linear system is actually semi-ample (some multiple is basepoint-free) by the Zariski--Fujita theorem.) 
In your example of the pencil of conics on a cubic surface, the pencil $|M|$ of conics is basepoint-free, so the corresponding map is actually a morphism extending your original rational map. (To see that the pencil of conics is actually basepoint-free, let $C$ be a conic in the pencil. Then $C+l$ is a plane section of the cubic, so $(C+l)^2=3$. On the other hand $C \cdot l = 2$ by Bezout, and $l^2=-1$, so we get $C^2=0$. Hence two distinct conics in the pencil are disjoint.)
