Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Fix plugin url for single-host mode (#869)
Browse files Browse the repository at this point in the history
* Fix plugin url for single host mode

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha authored Sep 30, 2020
1 parent c0d289a commit dc99f19
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,19 @@ export class ChePluginServiceImpl implements ChePluginService {
if (plugin.links && plugin.links.self) {
const self: string = plugin.links.self;
if (self.startsWith('/')) {
if (registry.uri === this.defaultRegistry.uri) {
// To work in both single host and multi host modes.
// In single host mode plugin registry url path is `plugin-registry/v3/plugins`,
// for multi host mode the path is `v3/plugins`. So, in both cases plugin registry url
// ends with `v3/plugins`, but ${plugin.links.self} starts with `/v3/plugins/${plugin.id}.
// See https://github.com/eclipse/che-plugin-registry/blob/master/build/scripts/index.sh#L27
// So the correct plugin url for both cases will be plugin registry url + plugin id.
if (registry.uri.endsWith('/')) {
return `${registry.uri}${plugin.id}/`;
} else {
return `${registry.uri}/${plugin.id}/`;
}
}
const uri = new URI(registry.uri);
return `${uri.scheme}://${uri.authority}${self}`;
} else {
Expand Down

0 comments on commit dc99f19

Please sign in to comment.