From 77575fdae02e2e7d91f58ef8333c89a6ae9faf73 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Wed, 6 Dec 2023 11:42:09 +0530 Subject: [PATCH] fix: git azure url special char support (#29319) ## Description Modifies git url regex to add support for special character (%) #### PR fixes following issue(s) Fixes #28061 #### Media image #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [x] Jest - [x] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed ## Summary by CodeRabbit - **Bug Fixes** - Improved URL validation to support Azure repository URLs with encoded spaces. - **Refactor** - Updated regular expression patterns to allow for additional characters in Git remote URLs, enhancing compatibility with various repository naming conventions. Co-authored-by: Aishwarya UR --- app/client/src/pages/Editor/gitSync/utils.test.ts | 2 ++ app/client/src/pages/Editor/gitSync/utils.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/client/src/pages/Editor/gitSync/utils.test.ts b/app/client/src/pages/Editor/gitSync/utils.test.ts index 0b0288391a..dce39bd598 100644 --- a/app/client/src/pages/Editor/gitSync/utils.test.ts +++ b/app/client/src/pages/Editor/gitSync/utils.test.ts @@ -29,6 +29,8 @@ const validUrls = [ "git@abcd.org:org__v3/(((something)/(other)/(thing).git", "git@gitlab-abcd.test.org:org__org/repoName.git", "git@gitlab__abcd.test.org:org__org/repoName.git", + "git@ssh.dev.azure.com:v3/something/with%20space%20(some)/geo-mantis", + "git@ssh.dev.azure.com:v3/something/with%20space%20some/geo-mantis", ]; const invalidUrls = [ diff --git a/app/client/src/pages/Editor/gitSync/utils.ts b/app/client/src/pages/Editor/gitSync/utils.ts index da5f3cf67d..7bcdbde494 100644 --- a/app/client/src/pages/Editor/gitSync/utils.ts +++ b/app/client/src/pages/Editor/gitSync/utils.ts @@ -19,7 +19,7 @@ export const getIsStartingWithRemoteBranches = ( }; const GIT_REMOTE_URL_PATTERN = - /^((git|ssh)|(git@[\w\-\.]+))(:(\/\/)?)([\w\.@\:\/\-~\(\)]+)[^\/]$/im; + /^((git|ssh)|(git@[\w\-\.]+))(:(\/\/)?)([\w\.@\:\/\-~\(\)%]+)[^\/]$/im; const gitRemoteUrlRegExp = new RegExp(GIT_REMOTE_URL_PATTERN);