Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit d7acdaa

Browse files
committed
(#478) navigo router: fixed reverse routing for certain base URLs
1 parent 526b068 commit d7acdaa

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Last Changes
44

5+
- [#478](https://github.com/LaxarJS/laxar/issues/478): navigo router: fixed reverse routing for certain base URLs
56
- [#469](https://github.com/LaxarJS/laxar/issues/469): flow: fixed `constructAbsoluteUrl` to not lose active place parameters
67
- [#472](https://github.com/LaxarJS/laxar/issues/472): bootstrapping: fixed a race condition that sometimes caused initialization to get stuck indefinitely
78
- [#470](https://github.com/LaxarJS/laxar/issues/470): project: upgrade to webpack 3

lib/runtime/navigo_router.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,14 @@ export function create( browser, configuration, Navigo = NavigoImplementation )
217217
* @memberof NavigoRouter
218218
*/
219219
function constructAbsoluteUrl( patterns, parameters, fragment = null ) {
220-
return router.link( ( useHash ? hash : '' ) + constructPath( patterns, parameters, fragment ) );
220+
const path = constructPath( patterns, parameters, fragment );
221+
const url = router.link( ( useHash ? hash : '' ) + path );
222+
223+
// peculiarity in Navigo: hash inserted twice if base ends with `/` (LaxarJS/laxar#478)
224+
const brokenSuffix = `/${hash}${hash}${path}`;
225+
return useHash && endsWith( url, brokenSuffix ) ?
226+
`${url.slice( 0, url.lastIndexOf( brokenSuffix ) )}/${hash}${path}` :
227+
url;
221228
}
222229

223230
///////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)