Skip to content

Commit 605e808

Browse files
committed
obtain valid url even baseurl is set (refs #2)
1 parent 03e8d2d commit 605e808

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/components/Root.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import Directory from './Directory';
55
export default class Root extends Directory {
66

77
componentWillMount() {
8-
// FIXME: exists altanarive way?
9-
const baseUrl = document.querySelector('header.main-header a.logo').getAttribute('href');
8+
// obtain repository URI
9+
// - localhost:8080/owner/repo -> /owner/repo
10+
// - localhost:8080/gitbucket/owner/repo -> /owner/repo
11+
const baseUrl = document.querySelector('header.main-header a.logo').getAttribute('href').replace(`${document.location.protocol}//${document.location.host}`, '');
1012
const relPath = document.location.pathname.replace(baseUrl, '');
1113
let rootPath;
1214
let branch;

0 commit comments

Comments
 (0)