fix: handle relative url case for OAuth

Description

This MR updates Web IDE to gracefully accept both trailing and non-trailing slash URL's for gitlabUrl when constructing OAuth URLs as a follow up to: gitlab!161328 (comment 2034468416).

Screenshot

correctly constructs OAuth URLs and loads Web IDE without relative URL:

Screenshot 2024-08-12 at 10.58.45 AM.png

correctly constructs OAuth URLs and loads Web IDE with relative URL:

Screenshot 2024-08-12 at 11.01.35 AM.png

How to test locally:

  • Pull this branch in gitlab-web-ide

  • There may be an issue with constructing the Web IDE static web assets when generating local development package. Apply the following patch to gitlab project:

    diff --git a/app/assets/javascripts/ide/lib/gitlab_web_ide/get_base_config.js b/app/assets/javascripts/ide/lib/gitlab_web_ide/get_base_config.js
    index c87d25b2a3f2..f8b6a4526261 100644
    --- a/app/assets/javascripts/ide/lib/gitlab_web_ide/get_base_config.js
    +++ b/app/assets/javascripts/ide/lib/gitlab_web_ide/get_base_config.js
    @@ -7,9 +7,11 @@ const getGitLabUrl = (gitlabPath = '') => {
       return cleanEndingSeparator(baseUrlObj.href);
     };
     
    +const mockPublicPath = '/assets/webpack/gitlab-vscode/0.0.1-dev-20240731185426/';
    +
     export const getBaseConfig = () => ({
       // baseUrl - The URL which hosts the Web IDE static web assets
    -  baseUrl: cleanEndingSeparator(getGitLabUrl(process.env.GITLAB_WEB_IDE_PUBLIC_PATH)),
    +  baseUrl: cleanEndingSeparator(getGitLabUrl(mockPublicPath)),
       // gitlabUrl - The URL for the GitLab instance
       gitlabUrl: getGitLabUrl(''),
     });
    
  • In the gitlab-web-ide project, run ./scripts/pack-web-ide-package.sh

  • Add the development package in the gitlab project by running yarn add <absolute_path_to_local_dev_package>

Edited by Cindy Halim

Merge request reports

Loading