0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-20 14:48:30 +02:00
This commit is contained in:
Kerwin Bryant 2025-01-14 03:36:19 +00:00
parent 459edfebcb
commit 9400d52ee9

View File

@ -96,4 +96,29 @@ export async function initViewFileTreeSidebar() {
loadContent(); loadContent();
}}); }});
fileTreeView.mount(fileTree); fileTreeView.mount(fileTree);
window.addEventListener('popstate', () => {
selectedItem.value = extractPath(window.location.href);
loadContent();
});
}
function extractPath(url) {
// Create a URL object
const urlObj = new URL(url);
// Get the pathname part
const path = urlObj.pathname;
// Define a regular expression to match "/{param1}/{param2}/src/{branch}/{main}/"
const regex = /^\/[^\/]+\/[^\/]+\/src\/[^\/]+\/[^\/]+\//;
// Use RegExp#exec() method to match the path
const match = regex.exec(path);
if (match) {
return path.substring(match[0].length);
}
// If the path does not match, return the original path
return path;
} }