[Workspace] Add base path when parsing url in http service#6233
[Workspace] Add base path when parsing url in http service#6233SuZhou-Joe merged 7 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6233 +/- ##
==========================================
+ Coverage 67.28% 67.33% +0.04%
==========================================
Files 3351 3351
Lines 65038 65037 -1
Branches 10475 10475
==========================================
+ Hits 43763 43793 +30
+ Misses 18704 18700 -4
+ Partials 2571 2544 -27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
… basePath enabled Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
|
LGTM, ship |
| describe('#getWorkspaceIdFromUrl', () => { | ||
| it('return workspace when there is a match', () => { | ||
| expect(getWorkspaceIdFromUrl('http://localhost/w/foo')).toEqual('foo'); | ||
| expect(getWorkspaceIdFromUrl('http://localhost/w/foo', '')).toEqual('foo'); |
There was a problem hiding this comment.
Q: why it need to specify '' as the second parameter explicitly?
There was a problem hiding this comment.
Maybe my question is more about why we need to change the getWorkspaceIdFromUrl function signature?
There was a problem hiding this comment.
- From the implementation perspective, the
basePathparameter is required when constructing the regular expression to parse the workspace id from url. - The bug comes from the loose function signature, I change it to a more strict signature so that others won't step into similar bug.
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-6233-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 0dce00a806bf8815ca84802541010767b6b3a8bd
# Push it to GitHub
git push --set-upstream origin backport/backport-6233-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.xThen, create a pull request where the |
…h-project#6233) * fix: add base path when parse url in http service Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add CHANGELOG Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize unit test cases for parse clientBasePath from url when basePath enabled Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add empty line before getWorkspaceIdFromURL method Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize comment Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize code Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com> Co-authored-by: Xinrui Bai-amazon <139305463+xinruiba@users.noreply.github.com> (cherry picked from commit 0dce00a)
…6451) * fix: add base path when parse url in http service Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add CHANGELOG Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize unit test cases for parse clientBasePath from url when basePath enabled Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add empty line before getWorkspaceIdFromURL method Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize comment Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize code Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com> Co-authored-by: Xinrui Bai-amazon <139305463+xinruiba@users.noreply.github.com> (cherry picked from commit 0dce00a)
Description
Make basePath required in
getWorkspaceIdFromUrlmethod.Issues Resolved
fixes #6015
Screenshot
Testing the changes
workspace.enabledto opensearch_dashboards.yml fileyarn startto enablebasePathfeature.fooworkspace:http://localhost:5603/{random_basePath}/w/foo/app/dev_toolsCheck List
yarn test:jestyarn test:jest_integration