|
166 | 166 | } |
167 | 167 | if (true === options.hashbang) hashbang = true; |
168 | 168 | if (!dispatch) return; |
169 | | - page.replace(page.getCurrentUrl(), null, true, dispatch); |
| 169 | + page.replace(page.getPath(), null, true, dispatch); |
170 | 170 | }; |
171 | 171 |
|
172 | 172 | /** |
|
355 | 355 | }; |
356 | 356 |
|
357 | 357 | /** |
358 | | - * Get the URL for cases that path is not provided. |
| 358 | + * Get the path for cases that it is not provided. |
359 | 359 | * |
360 | 360 | * Like: |
361 | 361 | * |
362 | 362 | * - page.start with dispatch is set to true. |
363 | 363 | * - On popstate event when state is not provided. |
| 364 | + * - Rebuild path on click event listener. |
364 | 365 | * |
365 | | - * @return {str} URL current URL location |
366 | | - */ |
367 | | - page.getCurrentUrl = function(){ |
368 | | - return (hashbang && ~location.hash.indexOf('#!')) ? location.hash.substr(2) + location.search : location.pathname + location.search + location.hash; |
| 366 | + * @param {object} location to generate path. |
| 367 | + * @return {str} path path generated. |
| 368 | + */ |
| 369 | + page.getPath = function(oLocation){ |
| 370 | + oLocation = oLocation || location; |
| 371 | + return (hashbang && ~oLocation.hash.indexOf('#!')) ? |
| 372 | + oLocation.hash.substr(2) + oLocation.search : |
| 373 | + oLocation.pathname + oLocation.search + oLocation.hash; |
369 | 374 | }; |
370 | 375 |
|
371 | 376 | /** |
|
543 | 548 | var path = e.state.path; |
544 | 549 | page.replace(path, e.state); |
545 | 550 | } else { |
546 | | - page.show(page.getCurrentUrl(), null, true, dispatch); |
| 551 | + page.show(page.getPath(), null, true, dispatch); |
547 | 552 | } |
548 | 553 | }; |
549 | 554 | })(); |
|
590 | 595 |
|
591 | 596 |
|
592 | 597 | // rebuild path |
593 | | - var path = el.pathname + el.search + (el.hash || ''); |
| 598 | + var path = page.getPath(el); |
594 | 599 |
|
595 | 600 | // strip leading "/[drive letter]:" on NW.js on Windows |
596 | 601 | if (typeof process !== 'undefined' && path.match(/^\/[a-zA-Z]:\//)) { |
|
0 commit comments