Skip to content

Commit d092dd6

Browse files
Avish34Avish Porwal
andauthored
Fix issue-743 by sanitizing the URL (#809)
<!-- Provide a brief summary of your changes --> This PR aims to fix #743 (comment) ## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> This is needed to ensure we are sanitizing the URL before creating server.json to be inline with the validations. ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> Tested via UTs and also tested CLI locally to ensure the expected behavior. ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [ ] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions --> Co-authored-by: Avish Porwal <avishporwal@microsoft.com>
1 parent 8191133 commit d092dd6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/publisher/commands/init.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ func detectDescription() string {
213213
}
214214

215215
func detectRepoURL() string {
216+
sanitizeURL := func(url string) string {
217+
return strings.TrimPrefix(url, "git+")
218+
}
219+
216220
// Try git remote
217221
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
218222
defer cancel()
@@ -233,11 +237,11 @@ func detectRepoURL() string {
233237
if json.Unmarshal(data, &pkg) == nil {
234238
if repo, ok := pkg["repository"].(map[string]any); ok {
235239
if url, ok := repo["url"].(string); ok {
236-
return strings.TrimSuffix(url, ".git")
240+
return sanitizeURL(strings.TrimSuffix(url, ".git"))
237241
}
238242
}
239243
if repo, ok := pkg["repository"].(string); ok {
240-
return strings.TrimSuffix(repo, ".git")
244+
return sanitizeURL(strings.TrimSuffix(repo, ".git"))
241245
}
242246
}
243247
}

0 commit comments

Comments
 (0)