This study investigates the mechanism of detonation propagation in a stoichiometric hydrogen-oxygen mixture with non-uniform flow velocity entering an expanding combustor. For simulation of the detonation propagation, the Navier-Stokes equations with a one-step two-species chemistry model are solved by employing the hybrid sixth-order weighted essentially non-oscillatory centre difference scheme. The self-sustaining mechanism of detonation propagation in an expanding combustor under the action of non-uniform supersonic flow with a velocity shear layer is revealed. The results show that under the influence of velocity shear layer, two different unburned jets are produced behind the detonation front. These jets are induced by the velocity shear layers and the Prandtl-Meyer expansion fan. The two jets interact and mix gradually. The interaction between the mixed unburned jets and highly unstable shear layers creates large-scale vortices that intensify the turbulent mixing of the unburned jets. Meanwhile, the baroclinic mechanism generates numerous vortices on the boundary of the unburned jet. These vortices promote the mixing of the burned and unburned gases, which eventually leads to the rapid consumption of the unburned pockets. The heat released due to the burning of the unreacted pockets behind the detonation wave, supports a self-sustaining propagation of the detonation wave. When the velocity difference among the shear layers increases, the surface fluctuation of the detonation wave increases.