@@ -206,7 +206,7 @@ class Router {
206206 replace = path . replace
207207 append = path . append
208208 }
209- path = this . _stringifyPath ( path )
209+ path = this . stringifyPath ( path )
210210 if ( path ) {
211211 this . history . go ( path , replace , append )
212212 }
@@ -295,6 +295,47 @@ class Router {
295295 this . _started = false
296296 }
297297
298+ /**
299+ * Normalize named route object / string paths into
300+ * a string.
301+ *
302+ * @param {Object|String|Number } path
303+ * @return {String }
304+ */
305+
306+ stringifyPath ( path ) {
307+ let fullPath = ''
308+ if ( path && typeof path === 'object' ) {
309+ if ( path . name ) {
310+ const extend = Vue . util . extend
311+ const currentParams =
312+ this . _currentTransition &&
313+ this . _currentTransition . to . params
314+ const targetParams = path . params || { }
315+ const params = currentParams
316+ ? extend ( extend ( { } , currentParams ) , targetParams )
317+ : targetParams
318+ if ( path . query ) {
319+ params . queryParams = path . query
320+ }
321+ fullPath = encodeURI ( this . _recognizer . generate ( path . name , params ) )
322+ } else if ( path . path ) {
323+ fullPath = encodeURI ( path . path )
324+ if ( path . query ) {
325+ const query = this . _recognizer . generateQueryString ( path . query )
326+ if ( fullPath . indexOf ( '?' ) > - 1 ) {
327+ fullPath += '&' + query . slice ( 1 )
328+ } else {
329+ fullPath += query
330+ }
331+ }
332+ }
333+ } else {
334+ fullPath = encodeURI ( path ? path + '' : '' )
335+ }
336+ return fullPath
337+ }
338+
298339 // Internal methods ======================================
299340
300341 /**
@@ -558,47 +599,6 @@ class Router {
558599 } )
559600 }
560601 }
561-
562- /**
563- * Normalize named route object / string paths into
564- * a string.
565- *
566- * @param {Object|String|Number } path
567- * @return {String }
568- */
569-
570- _stringifyPath ( path ) {
571- let fullPath = ''
572- if ( path && typeof path === 'object' ) {
573- if ( path . name ) {
574- const extend = Vue . util . extend
575- const currentParams =
576- this . _currentTransition &&
577- this . _currentTransition . to . params
578- const targetParams = path . params || { }
579- const params = currentParams
580- ? extend ( extend ( { } , currentParams ) , targetParams )
581- : targetParams
582- if ( path . query ) {
583- params . queryParams = path . query
584- }
585- fullPath = encodeURI ( this . _recognizer . generate ( path . name , params ) )
586- } else if ( path . path ) {
587- fullPath = encodeURI ( path . path )
588- if ( path . query ) {
589- const query = this . _recognizer . generateQueryString ( path . query )
590- if ( fullPath . indexOf ( '?' ) > - 1 ) {
591- fullPath += '&' + query . slice ( 1 )
592- } else {
593- fullPath += query
594- }
595- }
596- }
597- } else {
598- fullPath = encodeURI ( path ? path + '' : '' )
599- }
600- return fullPath
601- }
602602}
603603
604604/**
0 commit comments