The classic Stoker dam-break problem [1] is revisited in cases of different channel widths upstream and downstream of the dam. The channel is supposed to have a rectangular cross section and a horizontal and frictionless bottom. The system of the shallow water equations is enriched, using the width as a space-dependent variable, together with the depth and the unit discharge, which conversely depend on both space and time. Such a formulation allows a quasi-analytical treatment of the system, whose solution is similar to that of the classic Stoker solution when the downstream/upstream depth ratio is sufficiently large, except that a further stationary contact wave exists at the dam position. When the downstream/upstream depth ratio is small, the solution is richer than the Stoker solution because the critical state occurs at the dam position and the solution itself becomes resonant at the same position, where two eigenvalues are null and the strict hyperbolicity of the system is lost. The limits that identify the flow regime for channel contraction and channel expansion are discussed after showing that the nondimensional parameters governing the problem are the downstream/upstream width ratio and the downstream/upstream initial depth ratio.After the introduction of the previous analytical framework, a numerical analysis is also performed to evaluate a numerical method that is conceived to suitably capture rarefactions, shock waves and contact waves. A secondorder method is adopted, employing a Dumbser-Osher-Toro Riemann solver equipped with a nonlinear path. Such an original nonlinear path is shown to perform better than the classic linear path when contact waves of large amplitude must be captured, being able to obtain specific energy conservation and mass conservation at the singularity.The codes, written in MATLAB (MathWorks Inc.) language, are made available in Mendeley Data repository.