Skip to content

Commit 9344dfd

Browse files
committed
Fix how count is decremented when goUp pops path segments
1 parent 9520162 commit 9344dfd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

content_scripts/mode_normal.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ const NormalModeCommands = {
152152
}
153153

154154
// Pop path segments.
155-
if (c > 0 && url.pathname != "/") {
156-
url.pathname = url.pathname.split("/").slice(0, -c).join("/");
155+
if (c > 0 && url.pathname !== "/") {
156+
const initialSegments = url.pathname.substring(1).split('/');
157+
const segments = initialSegments.slice(0, -c);
158+
url.pathname = `/${segments.join('/')}`;
157159
url.search = "";
158160
url.hash = "";
159-
--c;
161+
c -= initialSegments.length - segments.length;
160162
}
161163

162164
if (globalThis.location.href !== url.toString()) {

0 commit comments

Comments
 (0)