@@ -246,7 +246,7 @@ var RouteNode = function () {
246246 strictQueryParams = options . strictQueryParams ,
247247 strongMatching = options . strongMatching ;
248248
249- var matchChildren = function matchChildren ( nodes , pathSegment , segments ) {
249+ var matchChildren = function matchChildren ( nodes , pathSegment , segments , consumedBefore ) {
250250 var isRoot = nodes . length === 1 && nodes [ 0 ] . name === '' ;
251251 // for (child of node.children) {
252252
@@ -256,13 +256,20 @@ var RouteNode = function () {
256256 // Partially match path
257257 var match = void 0 ;
258258 var remainingPath = void 0 ;
259+ var segment = pathSegment ;
260+
261+ if ( consumedBefore === '/' && child . path === '/' ) {
262+ // when we encounter repeating slashes we add the slash
263+ // back to the URL to make it de facto pathless
264+ segment = '/' + pathSegment ;
265+ }
259266
260267 if ( ! child . children . length ) {
261- match = child . parser . test ( pathSegment , { trailingSlash : trailingSlash } ) ;
268+ match = child . parser . test ( segment , { trailingSlash : trailingSlash } ) ;
262269 }
263270
264271 if ( ! match ) {
265- match = child . parser . partialTest ( pathSegment , { delimiter : strongMatching } ) ;
272+ match = child . parser . partialTest ( segment , { delimiter : strongMatching } ) ;
266273 }
267274
268275 if ( match ) {
@@ -272,13 +279,13 @@ var RouteNode = function () {
272279 consumedPath = consumedPath . replace ( / \/ $ / , '' ) ;
273280 }
274281
275- remainingPath = pathSegment . replace ( consumedPath , '' ) ;
282+ remainingPath = segment . replace ( consumedPath , '' ) ;
276283
277284 if ( trailingSlash && ! child . children . length ) {
278285 remainingPath = remainingPath . replace ( / ^ \/ \? / , '?' ) ;
279286 }
280287
281- var search = ( 0 , _searchParams . omit ) ( ( 0 , _searchParams . getSearch ) ( pathSegment . replace ( consumedPath , '' ) ) , child . parser . queryParams . concat ( child . parser . queryParamsBr ) ) ;
288+ var search = ( 0 , _searchParams . omit ) ( ( 0 , _searchParams . getSearch ) ( segment . replace ( consumedPath , '' ) ) , child . parser . queryParams . concat ( child . parser . queryParamsBr ) ) ;
282289 remainingPath = ( 0 , _searchParams . getPath ) ( remainingPath ) + ( search ? '?' + search : '' ) ;
283290 if ( trailingSlash && ! isRoot && remainingPath === '/' && ! / \/ $ / . test ( consumedPath ) ) {
284291 remainingPath = '' ;
@@ -318,7 +325,7 @@ var RouteNode = function () {
318325 }
319326 // Else: remaining path and children
320327 return {
321- v : matchChildren ( children , remainingPath , segments )
328+ v : matchChildren ( children , remainingPath , segments , consumedPath )
322329 } ;
323330 }
324331 } ;
@@ -405,7 +412,9 @@ var RouteNode = function () {
405412 var segmentPath = segment . parser . build ( params , { ignoreSearch : true } ) ;
406413
407414 return segment . absolute ? segmentPath : path + segmentPath ;
408- } , '' ) ;
415+ } , '' )
416+ // remove repeated slashes
417+ . replace ( / \/ \/ { 1 , } / g, '/' ) ;
409418
410419 var finalPath = path ;
411420
0 commit comments