Commit 02a2ca6a authored by Phil Hughes's avatar Phil Hughes

Fixes IDE button on merge requests not working with relative URL config

Closes #46438
parent 3094f1c1
......@@ -87,7 +87,7 @@ export function redirectTo(url) {
export function webIDEUrl(route = undefined) {
let returnUrl = `${gon.relative_url_root}/-/ide/`;
if (route) {
returnUrl += `project${route}`;
returnUrl += `project${route.replace(new RegExp(`^${gon.relative_url_root}`), '')}`;
}
return returnUrl;
}
---
title: Fixes Web IDE button on merge requests when GitLab is installed with relative
URL
merge_request:
author:
type: fixed
import { webIDEUrl } from '~/lib/utils/url_utility';
describe('URL utility', () => {
describe('webIDEUrl', () => {
describe('without relative_url_root', () => {
it('returns IDE path with route', () => {
expect(webIDEUrl('/gitlab-org/gitlab-ce/merge_requests/1')).toBe(
'/-/ide/project/gitlab-org/gitlab-ce/merge_requests/1',
);
});
});
describe('with relative_url_root', () => {
beforeEach(() => {
gon.relative_url_root = '/gitlab';
});
it('returns IDE path with route', () => {
expect(webIDEUrl('/gitlab/gitlab-org/gitlab-ce/merge_requests/1')).toBe(
'/gitlab/-/ide/project/gitlab-org/gitlab-ce/merge_requests/1',
);
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment