Skip to content
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

fix: uri root path checking #5778

Merged
merged 6 commits into from
May 14, 2024
Merged

fix: uri root path checking #5778

merged 6 commits into from
May 14, 2024

Conversation

Folyd
Copy link
Contributor

@Folyd Folyd commented Apr 14, 2024

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

This config will display Your service is accessible at https://my-domain.com//v2 after deploy successfully.

http:
  path: '/v2'

This PR fix this.

@Folyd Folyd requested a review from a team as a code owner April 14, 2024 23:09
@Folyd Folyd requested review from Lou1415926 and removed request for a team April 14, 2024 23:09
@Folyd Folyd changed the title Fix uri path root path checking Fix uri root path checking Apr 14, 2024
@@ -409,7 +409,7 @@ func (u *accessURI) strings() []string {
protocol = "https://"
}
path := ""
if u.Path != "/" {
if !strings.HasPrefix(Path, "/") {
path = fmt.Sprintf("/%s", u.Path)
}
uris = append(uris, color.HighlightResource(protocol+dnsName+path))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user adds a path without the / prefix, the path variable here will still be "". I think we need to catch this case. Thanks!

@huanjani
Copy link
Contributor

Hi, @Folyd! Thanks so much for opening this PR!
Would you mind adding a unit test to internal/pkg/describe/uri_test.go that tests this addition? Thanks!

@@ -409,7 +409,7 @@ func (u *accessURI) strings() []string {
protocol = "https://"
}
path := ""
if u.Path != "/" {
if !strings.HasPrefix(Path, "/") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if !strings.HasPrefix(Path, "/") {
if !strings.HasPrefix(u.Path, "/") {

@huanjani huanjani added do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. and removed do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. labels Apr 18, 2024
@Folyd
Copy link
Contributor Author

Folyd commented Apr 20, 2024

@huanjani Thanks for reviewing, I fixed it.

Copy link
Contributor

@dannyrandall dannyrandall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one small fix, but looks great otherwise! thanks for the fix and adding those test cases 😊

@@ -409,8 +409,10 @@ func (u *accessURI) strings() []string {
protocol = "https://"
}
path := ""
if u.Path != "/" {
Copy link
Contributor

@dannyrandall dannyrandall Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this misses a case with a path with multiple slashes, like ///foo. that should be solved by just changing the else if to an else (or drop the else like this)!

Suggested change
if u.Path != "/" {
path := u.Path
if !strings.HasPrefix(u.Path, "/") {
path = fmt.Sprintf("/%s", u.Path)
}

@iamhopaul123 iamhopaul123 changed the title Fix uri root path checking fix: uri root path checking May 10, 2024
Copy link

github-actions bot commented May 10, 2024

🍕 Here are the new binary sizes!

Name New size (kiB) size (kiB) Delta (%)
macOS (amd) 58072 57856 +0.37
macOS (arm) 59136 58908 +0.39
linux (amd) 50924 50732 +0.38
linux (arm) 50176 49988 +0.38
windows (amd) 47964 47784 +0.38

Copy link
Contributor

@huanjani huanjani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks so much!

@mergify mergify bot merged commit ae42fd8 into aws:mainline May 14, 2024
12 checks passed
@dannyrandall
Copy link
Contributor

The fix is now released in v1.33.4: /~https://github.com/aws/copilot-cli/releases/tag/v1.33.4! 🎉 Thanks @Folyd for the PR!

@Folyd Folyd deleted the fix-path-prefix branch August 28, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants