-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Workspace] Add base path when parsing url in http service #6233
[Workspace] Add base path when parsing url in http service #6233
Conversation
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
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 <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
LGTM, ship |
@@ -8,11 +8,11 @@ import { httpServiceMock } from '../public/mocks'; | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: why it need to specify ''
as the second parameter explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe my question is more about why we need to change the getWorkspaceIdFromUrl
function signature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- From the implementation perspective, the
basePath
parameter 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.x Then, create a pull request where the |
…h-project#6233) * fix: add base path when parse url in http service Signed-off-by: SuZhou-Joe <[email protected]> * feat: add CHANGELOG Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize unit test cases for parse clientBasePath from url when basePath enabled Signed-off-by: SuZhou-Joe <[email protected]> * feat: add empty line before getWorkspaceIdFromURL method Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize comment Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: Xinrui Bai-amazon <[email protected]> (cherry picked from commit 0dce00a)
…6451) * fix: add base path when parse url in http service Signed-off-by: SuZhou-Joe <[email protected]> * feat: add CHANGELOG Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize unit test cases for parse clientBasePath from url when basePath enabled Signed-off-by: SuZhou-Joe <[email protected]> * feat: add empty line before getWorkspaceIdFromURL method Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize comment Signed-off-by: SuZhou-Joe <[email protected]> * feat: optimize code Signed-off-by: SuZhou-Joe <[email protected]> --------- Signed-off-by: SuZhou-Joe <[email protected]> Co-authored-by: Xinrui Bai-amazon <[email protected]> (cherry picked from commit 0dce00a)
Description
Make basePath required in
getWorkspaceIdFromUrl
method.Issues Resolved
fixes #6015
Screenshot
Testing the changes
workspace.enabled
to opensearch_dashboards.yml fileyarn start
to enablebasePath
feature.foo
workspace:http://localhost:5603/{random_basePath}/w/foo/app/dev_tools
Check List
yarn test:jest
yarn test:jest_integration