Skip to content

Commit c6f6ce2

Browse files
Refactor: Route URL Method
1 parent 6377604 commit c6f6ce2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

package/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ const mode = {
99
const linkFiber = require('./linkFiber')(snapShot, mode);
1010
const timeJump = require('./timeJump')(snapShot, mode);
1111

12-
let url = '/';
1312
function getRouteURL(node) {
1413
if (node.name === 'Router') {
15-
url = node.state.location.pathname;
14+
return node.state.location.pathname;
1615
}
1716
if (node.children.length >= 1) {
1817
const tempNode = node.children;
1918
for (let index = 0; index < tempNode.length; index += 1) {
20-
getRouteURL(tempNode[index]);
19+
return getRouteURL(tempNode[index]);
2120
}
2221
}
2322
}
@@ -26,10 +25,9 @@ window.addEventListener('message', ({ data: { action, payload } }) => { // runs
2625
switch (action) {
2726
case 'jumpToSnap':
2827
timeJump(payload);
29-
getRouteURL(payload);
3028
// Get the pathname from payload and add new entry to browser history
3129
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
32-
window.history.pushState('', '', url);
30+
window.history.pushState('', '', getRouteURL(payload));
3331
break;
3432
case 'setLock':
3533
mode.locked = payload;

0 commit comments

Comments
 (0)