Open puff-tw opened 1 year ago
Hey @puff-tw! The reason we assumed GitLab is hosted on a subdomain is because GitLab recommends you to host your git instance on a subdomain rather than on a relative url.
As you can see in the code we've hardcoded the API url to be in the form of SUBDOMAIN.DOMAIN.XYZ
/api/v4/projects/
.
Furthermore I have tried working out a solution where the extension could pickup the relative URL from GitLab itself, but found no luck there. (Was reported by @huzisuke in https://github.com/tavyandy97/span-tree/issues/77 but closed it due to no feasible solution)
The solution you are recommending is that we have a custom field where we can punch in the relative URL? Where do you recommend we put the option?
One possible place I could figure out would be the extension popup -
The solution you are recommending is that we have a custom field where we can punch in the relative URL? Where do you recommend we put the option?
One possible place I could figure out would be the extension popup -
That sounds like a feasible approach. Placing the option in the extension popup could work well.
I'll try working on that in this week, will keep you updated on this issue 😄
Thanks for requesting the feature and helping making SpanTree a better extension 🌳
Was reported by @huzisuke in https://github.com/tavyandy97/span-tree/issues/77 but closed it due to no feasible solution
on gitlab page it has global variable gon
// tested on gitlab-ce 11.4.5, gitlab 14.4.1-ee
> gon.gitlab_url
'https://demo-site.com/gitlab'
> gon.relative_url_root
'/gitlab'
is this info enough for api url detect? @tavyandy97
One possible place I could figure out would be the extension popup
if it have to leave a setting entry on GUI,
is it possible to place it at the span-tree main-panel,
which is easier to reach than extention icon (normal collapsed) menu
(like the octotree setting icon)
seems chrome extension js can't directly access page global variable. I'm not familar with extension delelop, I just did a rough workaround to verify feasibility:
// it's based on content.js
(from 0.0.5.0 extension dir) , formated by chrome F12
+var base_url = (document.head.innerHTML.match(/;gon.gitlab_url="(.*?)";/) || [,window.location.origin])[1];
+console.log('---spantree:', base_url);
var r = t(9669)
, i = t.n(r)
, o = t(3955);
const a = {
- baseURL: `${window.location.origin}/api/v4/projects/`
+ baseURL: `${base_url}/api/v4/projects/`
}
it works ( via chrome load unpacked
modified extension dir )
TODO: check URI to defense injection
src maybe correspond here https://github.com/tavyandy97/span-tree/blob/v0.0.4.2/event/axios.js#L4
I send a PR here https://github.com/tavyandy97/span-tree/pull/92
@tavyandy97
I noticed a 404 error because the Extension was using an incorrect API URL. This is because my Gitlab installation is located in a subdirectory, like this: https://SITE_DOMAIN/gitlab/.
The incorrect URL was: https://SITE_DOMAIN/api/v4/projects/123/repository/tree?per_page=10000&ref=master
The correct URL is: https://SITE_DOMAIN/gitlab/api/v4/projects/123/repository/tree?per_page=10000&ref=master
Since Gitlab is installed in a subdirectory, the correct URL needs to include the subdirectory path (/gitlab/) before the api endpoint.
Is it possible to configure the API URL on the Extension itself?