grapetreeCore.js
function getNewRouteInfo(that, newRoutePath, path, pathToEmit) {
        var indexes = getDivergenceIndexes(that.currentPath, path, newRoutePath)
        if(indexes === undefined) {
            return undefined
        }

        var routeDivergenceIndex = indexes.routeIndex
        var pathDivergenceIndex = indexes.pathIndex
        var lastRoute = newRoutePath[routeDivergenceIndex-1].route
        var newPathSegment = path.slice(pathDivergenceIndex)

        // routing
        var newRoutes = traverseRoute(that, lastRoute, newPathSegment, pathDivergenceIndex)
        if(newRoutes ===  undefined) {
            var pathAdditions = []
            for(var n=routeDivergenceIndex-1; n>=0; n--) { // go in reverse and take the closest default handler
                if(that.currentRoutes[n].route.defaultHandler !== undefined) {
                    var defaultHandler = that.currentRoutes[n].route.defaultHandler
                    break;
                } else {
                    pathAdditions = that.currentRoutes[n].route.pathSegment.concat(pathAdditions)
                }
            }

            if(defaultHandler !== undefined) {
                var handlerParameters = [getPathSegementToOutput(that.transform, pathAdditions.concat(newPathSegment))]

                var subroute = new Route(newPathSegment, that.transform, true)
                defaultHandler.apply(subroute, handlerParameters)

                var pathIndexEnd = pathDivergenceIndex+newPathSegment.length
                if(newPathSegment.length !== 0) {
                    pathIndexEnd--
                }
                newRoutes = [{route: subroute, pathIndexes: {start:pathDivergenceIndex, end: pathIndexEnd}}]
            } else {
                throw new Error("No route matched path: "+JSON.stringify(getPathToOutput(that.transform, path)))
            }
        } else {
            var newRouteInfo = getRedirectRoute(that, path, newRoutePath, newRoutes, routeDivergenceIndex)
            if(newRouteInfo !== false) {
                return newRouteInfo
            }
        }

        return {newRoutes: newRoutes, divergenceIndex: routeDivergenceIndex, pathToEmit: pathToEmit}
    }
function getNewRouteInfo(that, newRoutePath, path, pathToEmit) {
        var indexes = getDivergenceIndexes(that.currentPath, path, newRoutePath)
        if(indexes === undefined) {
            return undefined
        }

        var routeDivergenceIndex = indexes.routeIndex
        var pathDivergenceIndex = indexes.pathIndex
        var lastRoute = newRoutePath[routeDivergenceIndex-1].route
        var newPathSegment = path.slice(pathDivergenceIndex)

        // routing
        var newRoutes = traverseRoute(that, lastRoute, newPathSegment, pathDivergenceIndex)
        if(newRoutes ===  undefined) {
            var pathAdditions = []
            for(var n=routeDivergenceIndex-1; n>=0; n--) { // go in reverse and take the closest default handler
                if(that.currentRoutes[n].route.defaultHandler !== undefined) {
                    var defaultHandler = that.currentRoutes[n].route.defaultHandler
                    break;
                } else {
                    pathAdditions = that.currentRoutes[n].route.pathSegment.concat(pathAdditions)
                }
            }

            if(defaultHandler !== undefined) {
                var handlerParameters = [getPathSegementToOutput(that.transform, pathAdditions.concat(newPathSegment))]

                var subroute = new Route(newPathSegment, that.transform, true)
                defaultHandler.apply(subroute, handlerParameters)

                var pathIndexEnd = pathDivergenceIndex+newPathSegment.length
                if(newPathSegment.length !== 0) {
                    pathIndexEnd--
                }
                newRoutes = [{route: subroute, pathIndexes: {start:pathDivergenceIndex, end: pathIndexEnd}}]
            } else {
                throw new Error("No route matched path: "+JSON.stringify(getPathToOutput(that.transform, path)))
            }
        } else {
            var newRouteInfo = getRedirectRoute(that, path, newRoutePath, newRoutes, routeDivergenceIndex)
            if(newRouteInfo !== false) {
                return newRouteInfo
            }
        }

        return {newRoutes: newRoutes, divergenceIndex: routeDivergenceIndex, pathToEmit: pathToEmit}
    }
function getNewRouteInfo ( that , newRoutePath , path , pathToEmit ) { var indexes = getDivergenceIndexes ( that . currentPath , path , newRoutePath ) if ( indexes === undefined ) { return undefined } var routeDivergenceIndex = indexes . routeIndex var pathDivergenceIndex = indexes . pathIndex var lastRoute = newRoutePath [ routeDivergenceIndex - 1 ] . route var newPathSegment = path . slice ( pathDivergenceIndex ) // routing var newRoutes = traverseRoute ( that , lastRoute , newPathSegment , pathDivergenceIndex ) if ( newRoutes === undefined ) { var pathAdditions = [ ] for ( var n = routeDivergenceIndex - 1 ; n >= 0 ; n -- ) { // go in reverse and take the closest default handler if ( that . currentRoutes [ n ] . route . defaultHandler !== undefined ) { var defaultHandler = that . currentRoutes [ n ] . route . defaultHandler break ; } else { pathAdditions = that . currentRoutes [ n ] . route . pathSegment . concat ( pathAdditions ) } } if ( defaultHandler !== undefined ) { var handlerParameters = [ getPathSegementToOutput ( that . transform , pathAdditions . concat ( newPathSegment ) ) ] var subroute = new Route ( newPathSegment , that . transform , true ) defaultHandler . apply ( subroute , handlerParameters ) var pathIndexEnd = pathDivergenceIndex + newPathSegment . length if ( newPathSegment . length !== 0 ) { pathIndexEnd -- } newRoutes = [ { route : subroute , pathIndexes : { start : pathDivergenceIndex , end : pathIndexEnd } } ] } else { throw new Error ( "No route matched path: " + JSON . stringify ( getPathToOutput ( that . transform , path ) ) ) } } else { var newRouteInfo = getRedirectRoute ( that , path , newRoutePath , newRoutes , routeDivergenceIndex ) if ( newRouteInfo !== false ) { return newRouteInfo } } return { newRoutes : newRoutes , divergenceIndex : routeDivergenceIndex , pathToEmit : pathToEmit } }
returns an object with the properties newRoutes - an array of Route objects; the list of new routes to enter divergenceIndex - the route divergence index pathToEmit - the path to use when emitting the 'change' event or undefined - if the paths are the same
returns an object with the properties newRoutes - an array of Route objects ; the list of new routes to enter divergenceIndex - the route divergence index pathToEmit - the path to use when emitting the change event or undefined - if the paths are the same