Skip to content
This repository was archived by the owner on Jun 22, 2026. It is now read-only.

fix: uri root path checking - #5778

Merged
mergify[bot] merged 6 commits into
aws:mainlinefrom
Folyd:fix-path-prefix
May 14, 2024
Merged

mergify[bot] merged 6 commits into
aws:mainlinefrom
Folyd:fix-path-prefix

Conversation

@Folyd

@Folyd Folyd commented Apr 14, 2024

Copy link
Copy Markdown
Contributor

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
if !strings.HasPrefix(Path, "/") {
path = fmt.Sprintf("/%s", u.Path)
}
uris = append(uris, color.HighlightResource(protocol+dnsName+path))

Copy link
Copy Markdown
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
Copy Markdown
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!

Comment thread internal/pkg/describe/uri.go Outdated
}
path := ""
if u.Path != "/" {
if !strings.HasPrefix(Path, "/") {

Copy link
Copy Markdown
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

Folyd commented Apr 20, 2024

Copy link
Copy Markdown
Contributor Author

@huanjani Thanks for reviewing, I fixed it.

@dannyrandall dannyrandall left a comment

Copy link
Copy Markdown
Contributor

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 😊

protocol = "https://"
}
path := ""
if u.Path != "/" {

@dannyrandall dannyrandall Apr 29, 2024 •

Copy link
Copy Markdown
Contributor

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
@github-actions

github-actions Bot commented May 10, 2024 •

Copy link
Copy Markdown

🍕 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

@huanjani huanjani left a comment

Copy link
Copy Markdown
Contributor

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
@dannyrandall

Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants